22 #ifndef SCUMM_MACGUI_MACGUI_IMPL_H 23 #define SCUMM_MACGUI_MACGUI_IMPL_H 25 #define TEXT_END_MARKER { 0, 0, kStyleRegular, Graphics::kTextAlignLeft, nullptr } 27 #include "common/events.h" 28 #include "common/hashmap.h" 29 #include "common/rect.h" 30 #include "common/str.h" 31 #include "common/str-array.h" 33 #include "engines/engine.h" 35 #include "graphics/font.h" 36 #include "graphics/surface.h" 40 #define kDialogQuit -1 41 #define kDialogWantsAttention -2 47 class MacWindowManager;
61 kMSIAboutGameName = 1,
63 kMSIAreYouSureYouWantToQuit,
64 kMSIAreYouSureYouWantToRestart,
118 ParsingMethod parsingMethod;
143 bool _paletteDirty =
false;
145 bool _menuIsActive =
false;
146 bool _cursorWasVisible =
false;
151 int _gameFontId = -1;
153 byte _unicodeToMacRoman[96];
157 kDelayInterrupted = 1,
168 kAboutFontHeaderInside,
169 kAboutFontHeaderOutside,
171 kAboutFontHeaderSimple1,
172 kAboutFontHeaderSimple2,
176 kIndy3VerbFontRegular,
178 kIndy3VerbFontOutline,
204 enum MacDialogWindowStyle {
209 enum MacDialogMenuStyle {
215 MacGuiImpl::DelayStatus delay(uint32 ms = 0);
217 virtual bool getFontParams(FontId fontId,
int &
id,
int &size,
int &slant)
const;
223 virtual void runAboutDialog() = 0;
224 virtual bool runOpenDialog(
int &saveSlotToHandle);
225 virtual bool runSaveDialog(
int &saveSlotToHandle,
Common::String &saveName);
226 virtual bool runOptionsDialog() = 0;
227 void prepareSaveLoad(
Common::StringArray &savegameNames,
bool *availSlots,
int *slotIds,
int size);
232 void parseSTRSBlock(uint8 *strsData,
const MacSTRSParsingEntry *parsingTable,
int parsingTableSize);
242 bool _redraw =
false;
243 bool _enabled =
false;
244 bool _visible =
true;
251 bool getRedraw()
const {
return _redraw; }
252 bool isEnabled()
const {
return _enabled; }
253 bool isVisible()
const {
return _visible; }
263 MacWidgetType _type = kWidgetUnknown;
265 bool _fullRedraw =
false;
271 void drawBitmap(
Common::Rect r,
const uint16 *bitmap, uint32 color)
const;
277 void setId(
int id) { _id = id; }
278 int getId()
const {
return _id; }
280 void setType(MacWidgetType type) { _type = type; }
281 MacWidgetType getType() {
return _type; }
285 void setVisible(
bool visible) { _visible = visible; }
287 virtual void getFocus() { setRedraw(); }
288 virtual void loseFocus() { setRedraw(); }
290 virtual void setRedraw(
bool fullRedraw =
false);
292 void setEnabled(
bool enabled);
294 virtual void setValue(
int value);
295 int getValue()
const {
return _value; }
299 virtual bool useBeamCursor() {
return false; }
300 virtual bool findWidget(
int x,
int y)
const;
301 virtual bool shouldDeferAction() {
return false; }
303 virtual void draw(
bool drawFocused =
false) = 0;
306 virtual bool handleDoubleClick(
Common::Event &event) {
return false; }
307 virtual bool handleMouseUp(
Common::Event &event) {
return false; }
309 virtual void handleMouseHeld() {}
310 virtual void handleWheelUp() {}
311 virtual void handleWheelDown() {}
312 virtual bool handleKeyDown(
Common::Event &event) {
return false; }
322 void hLine(
int x0,
int y0,
int x1,
bool enabled);
323 void vLine(
int x0,
int y0,
int y1,
bool enabled);
324 void drawCorners(
Common::Rect r, CornerLine *corner,
bool enabled);
329 void draw(
bool drawFocused =
false);
341 bool findWidget(
int x,
int y)
const;
342 void draw(
bool drawFocused =
false);
355 bool _wordWrap =
false;
362 _alignment = alignment;
370 void setWordWrap(
bool wordWrap) { _wordWrap = wordWrap; }
379 void setColor(uint32 fg, uint32 bg) {
380 if (fg != _fg || bg != _bg) {
387 void draw(
bool drawFocused =
false);
394 uint _maxLength = 31;
401 uint32 _nextCaretBlink = 0;
402 bool _caretVisible =
true;
407 int getTextPosFromMouse(
int x,
int y);
409 void updateSelection(
int x,
int y);
410 void deleteSelection();
415 void getFocus()
override {}
416 void loseFocus()
override {}
420 bool useBeamCursor()
override {
return true; }
421 bool findWidget(
int x,
int y)
const override;
422 bool shouldDeferAction()
override {
return true; }
424 void draw(
bool drawFocused =
false)
override;
429 void handleMouseHeld()
override;
443 void draw(
bool drawFocused =
false);
453 int _grabOffset = -1;
455 int calculateValueFromPos()
const;
456 int calculatePosFromValue()
const;
460 :
MacWidget(window, bounds,
"SliderBase", enabled),
461 _minValue(minValue), _maxValue(maxValue),
462 _minPos(minPos), _maxPos(maxPos) {}
467 void setValue(
int value);
473 uint32 _nextRepeat = 0;
478 bool _upArrowPressed =
false;
479 bool _downArrowPressed =
false;
489 void drawUpArrow(
bool markAsDirty);
490 void drawDownArrow(
bool markAsDirty);
491 void drawArrow(
Common::Rect r,
const uint16 *bitmap,
bool markAsDirty);
493 void eraseDragHandle();
499 bool isScrollable()
const {
return (_maxValue - _minValue) > 0; }
500 int getPageSize()
const {
return _pageSize; }
502 bool findWidget(
int x,
int y)
const;
503 void draw(
bool drawFocued =
false);
504 void redrawHandle(
int oldValue,
int newValue);
509 void handleMouseHeld();
510 void handleWheelUp();
511 void handleWheelDown();
526 :
MacSliderBase(window, background->getBounds(), minValue, maxValue, minX + leftMargin, maxX - rightMargin, enabled),
527 _background(background), _handle(handle), _minX(minX),
530 bool findWidget(
int x,
int y)
const;
531 void draw(
bool drawFocused =
false);
536 void handleWheelUp();
537 void handleWheelDown();
545 bool _sliderFocused =
false;
548 void handleWheel(
int distance);
557 void setValue(
int value) {
558 if (value != _value) {
568 bool findWidget(
int x,
int y)
const;
569 void setRedraw(
bool fullRedraw =
false);
570 void draw(
bool drawFocused =
false);
576 void handleMouseHeld();
577 void handleWheelUp();
578 void handleWheelDown();
587 bool _shakeWasEnabled;
592 bool _visible =
false;
594 uint32 _lastClickTime = 0;
599 bool _cursorWasVisible =
false;
600 bool _beamCursorVisible =
false;
601 const int _beamCursorHotspotX = 3;
602 const int _beamCursorHotspotY = 4;
604 void drawBeamCursor();
605 void undrawBeamCursor();
629 void addWidget(
MacWidget *widget, MacWidgetType type);
641 bool isVisible()
const {
return _visible; }
647 MacWidget *getWidget(MacWidgetType type,
int nr = 0)
const;
649 void setDefaultWidget(
MacWidget *widget) { _defaultWidget = widget; }
650 MacWidget *getDefaultWidget()
const {
return _defaultWidget; }
652 void setFocusedWidget(
int x,
int y);
653 void clearFocusedWidget();
654 MacWidget *getFocusedWidget()
const {
return _focusedWidget; }
658 int findWidget(
int x,
int y)
const;
665 MacGuiImpl::MacSlider *addSlider(
int x,
int y,
int h,
int minValue,
int maxValue,
int pageSize,
bool enabled);
666 MacGuiImpl::MacPictureSlider *addPictureSlider(
int backgroundId,
int handleId,
bool enabled,
int minX,
int maxX,
int minValue,
int maxValue,
int leftMargin = 0,
int rightMargin = 0);
670 void replaceSubstitution(
int nr,
Common::String text) { _substitutions[nr] = text; }
672 bool hasSubstitution(uint n)
const {
return n < _substitutions.
size(); }
673 Common::String &getSubstitution(uint n) {
return _substitutions[n]; }
676 void update(
bool fullRedraw =
false);
678 static void plotPixel(
int x,
int y,
int color,
void *data);
679 static void plotPattern(
int x,
int y,
int pattern,
void *data);
680 static void plotPatternDarkenOnly(
int x,
int y,
int pattern,
void *data);
682 void drawDottedHLine(
int x0,
int y,
int x1);
683 void fillPattern(
Common::Rect r, uint16 pattern,
bool fillBlack =
true,
bool fillWhite =
true);
694 bool _forceMenuClosed =
false;
696 virtual int getNumColors()
const = 0;
699 uint32 getBlack()
const;
700 uint32 getWhite()
const;
707 int toMacRoman(
int unicode)
const;
709 void setPaletteDirty();
710 void updatePalette();
714 static void menuCallback(
int id,
Common::String &name,
void *data);
715 virtual bool initialize();
716 void updateWindowManager();
723 virtual bool isVerbGuiActive()
const {
return false; }
724 virtual void reset() {}
725 virtual void resetAfterLoad() = 0;
726 virtual void update(
int delta) = 0;
728 bool runQuitDialog();
729 bool runRestartDialog();
731 virtual void setupCursor(
int &width,
int &height,
int &hotspotX,
int &hotspotY,
int &animate) = 0;
734 virtual void clearTextArea() {}
735 virtual void initTextAreaForActor(
Actor *a, byte color) {}
736 virtual void printCharToTextArea(
int chr,
int x,
int y,
int color) {}
738 MacDialogWindow *createWindow(
Common::Rect bounds, MacDialogWindowStyle style = kWindowStyleNormal, MacDialogMenuStyle menuStyle = kMenuStyleDisabled);
740 void drawBanner(
char *message);
Definition: macgui_impl.h:55
Definition: macgui_impl.h:470
TextAlign
Definition: font.h:48
Definition: macgui_impl.h:350
Definition: macgui_impl.h:334
Align the text to the left.
Definition: font.h:51
Definition: macgui_impl.h:390
Definition: macwindowmanager.h:149
Definition: macgui_impl.h:514
Definition: macgui_impl.h:540
void push_back(const T &element)
Definition: array.h:180
Definition: macgui_impl.h:582
Definition: formatinfo.h:28
size_type size() const
Definition: array.h:315
Definition: macgui_impl.h:239
Definition: macgui_impl.h:433
signed char * fill(signed char *first, signed char *last, Value val)
Definition: algorithm.h:168
Definition: macgui_impl.h:116
Definition: macgui_impl.h:446
Definition: macgui_impl.h:196