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 _menuIsActive =
false;
144 bool _cursorWasVisible =
false;
149 int _gameFontId = -1;
151 byte _unicodeToMacRoman[96];
155 kDelayInterrupted = 1,
166 kAboutFontHeaderInside,
167 kAboutFontHeaderOutside,
169 kAboutFontHeaderSimple1,
170 kAboutFontHeaderSimple2,
174 kIndy3VerbFontRegular,
176 kIndy3VerbFontOutline,
202 enum MacDialogWindowStyle {
207 enum MacDialogMenuStyle {
213 MacGuiImpl::DelayStatus delay(uint32 ms = 0);
215 virtual bool getFontParams(FontId fontId,
int &
id,
int &size,
int &slant)
const;
221 virtual void runAboutDialog() = 0;
222 virtual bool runOpenDialog(
int &saveSlotToHandle);
223 virtual bool runSaveDialog(
int &saveSlotToHandle,
Common::String &saveName);
224 virtual bool runOptionsDialog() = 0;
225 void prepareSaveLoad(
Common::StringArray &savegameNames,
bool *availSlots,
int *slotIds,
int size);
230 void parseSTRSBlock(uint8 *strsData,
MacSTRSParsingEntry *parsingTable,
int parsingTableSize);
240 bool _redraw =
false;
241 bool _enabled =
false;
242 bool _visible =
true;
249 bool getRedraw()
const {
return _redraw; }
250 bool isEnabled()
const {
return _enabled; }
251 bool isVisible()
const {
return _visible; }
261 MacWidgetType _type = kWidgetUnknown;
263 bool _fullRedraw =
false;
269 void drawBitmap(
Common::Rect r,
const uint16 *bitmap, uint32 color)
const;
275 void setId(
int id) { _id = id; }
276 int getId()
const {
return _id; }
278 void setType(MacWidgetType type) { _type = type; }
279 MacWidgetType getType() {
return _type; }
283 void setVisible(
bool visible) { _visible = visible; }
285 virtual void getFocus() { setRedraw(); }
286 virtual void loseFocus() { setRedraw(); }
288 virtual void setRedraw(
bool fullRedraw =
false);
290 void setEnabled(
bool enabled);
292 virtual void setValue(
int value);
293 int getValue()
const {
return _value; }
297 virtual bool useBeamCursor() {
return false; }
298 virtual bool findWidget(
int x,
int y)
const;
299 virtual bool shouldDeferAction() {
return false; }
301 virtual void draw(
bool drawFocused =
false) = 0;
304 virtual bool handleDoubleClick(
Common::Event &event) {
return false; }
305 virtual bool handleMouseUp(
Common::Event &event) {
return false; }
307 virtual void handleMouseHeld() {}
308 virtual void handleWheelUp() {}
309 virtual void handleWheelDown() {}
310 virtual bool handleKeyDown(
Common::Event &event) {
return false; }
320 void hLine(
int x0,
int y0,
int x1,
bool enabled);
321 void vLine(
int x0,
int y0,
int y1,
bool enabled);
322 void drawCorners(
Common::Rect r, CornerLine *corner,
bool enabled);
327 void draw(
bool drawFocused =
false);
339 bool findWidget(
int x,
int y)
const;
340 void draw(
bool drawFocused =
false);
353 bool _wordWrap =
false;
360 _alignment = alignment;
368 void setWordWrap(
bool wordWrap) { _wordWrap = wordWrap; }
377 void setColor(uint32 fg, uint32 bg) {
378 if (fg != _fg || bg != _bg) {
385 void draw(
bool drawFocused =
false);
392 uint _maxLength = 31;
399 uint32 _nextCaretBlink = 0;
400 bool _caretVisible =
true;
405 int getTextPosFromMouse(
int x,
int y);
407 void updateSelection(
int x,
int y);
408 void deleteSelection();
413 void getFocus()
override {}
414 void loseFocus()
override {}
418 bool useBeamCursor()
override {
return true; }
419 bool findWidget(
int x,
int y)
const override;
420 bool shouldDeferAction()
override {
return true; }
422 void draw(
bool drawFocused =
false)
override;
427 void handleMouseHeld()
override;
441 void draw(
bool drawFocused =
false);
451 int _grabOffset = -1;
453 int calculateValueFromPos()
const;
454 int calculatePosFromValue()
const;
458 :
MacWidget(window, bounds,
"SliderBase", enabled),
459 _minValue(minValue), _maxValue(maxValue),
460 _minPos(minPos), _maxPos(maxPos) {}
465 void setValue(
int value);
476 bool _upArrowPressed =
false;
477 bool _downArrowPressed =
false;
487 void drawUpArrow(
bool markAsDirty);
488 void drawDownArrow(
bool markAsDirty);
489 void drawArrow(
Common::Rect r,
const uint16 *bitmap,
bool markAsDirty);
491 void eraseDragHandle();
497 bool isScrollable()
const {
return (_maxValue - _minValue) > 0; }
498 int getPageSize()
const {
return _pageSize; }
500 bool findWidget(
int x,
int y)
const;
501 void draw(
bool drawFocued =
false);
502 void redrawHandle(
int oldValue,
int newValue);
507 void handleMouseHeld();
508 void handleWheelUp();
509 void handleWheelDown();
524 :
MacSliderBase(window, background->getBounds(), minValue, maxValue, minX + leftMargin, maxX - rightMargin, enabled),
525 _background(background), _handle(handle), _minX(minX),
528 bool findWidget(
int x,
int y)
const;
529 void draw(
bool drawFocused =
false);
534 void handleWheelUp();
535 void handleWheelDown();
543 bool _sliderFocused =
false;
546 void handleWheel(
int distance);
555 void setValue(
int value) {
556 if (value != _value) {
566 bool findWidget(
int x,
int y)
const;
567 void setRedraw(
bool fullRedraw =
false);
568 void draw(
bool drawFocused =
false);
574 void handleMouseHeld();
575 void handleWheelUp();
576 void handleWheelDown();
585 bool _shakeWasEnabled;
590 bool _visible =
false;
592 uint32 _lastClickTime = 0;
597 bool _cursorWasVisible =
false;
598 bool _beamCursorVisible =
false;
599 const int _beamCursorHotspotX = 3;
600 const int _beamCursorHotspotY = 4;
602 void drawBeamCursor();
603 void undrawBeamCursor();
627 void addWidget(
MacWidget *widget, MacWidgetType type);
639 bool isVisible()
const {
return _visible; }
645 MacWidget *getWidget(MacWidgetType type,
int nr = 0)
const;
647 void setDefaultWidget(
MacWidget *widget) { _defaultWidget = widget; }
648 MacWidget *getDefaultWidget()
const {
return _defaultWidget; }
650 void setFocusedWidget(
int x,
int y);
651 void clearFocusedWidget();
652 MacWidget *getFocusedWidget()
const {
return _focusedWidget; }
656 int findWidget(
int x,
int y)
const;
663 MacGuiImpl::MacSlider *addSlider(
int x,
int y,
int h,
int minValue,
int maxValue,
int pageSize,
bool enabled);
664 MacGuiImpl::MacPictureSlider *addPictureSlider(
int backgroundId,
int handleId,
bool enabled,
int minX,
int maxX,
int minValue,
int maxValue,
int leftMargin = 0,
int rightMargin = 0);
668 void replaceSubstitution(
int nr,
Common::String text) { _substitutions[nr] = text; }
670 bool hasSubstitution(uint n)
const {
return n < _substitutions.
size(); }
671 Common::String &getSubstitution(uint n) {
return _substitutions[n]; }
674 void update(
bool fullRedraw =
false);
676 static void plotPixel(
int x,
int y,
int color,
void *data);
677 static void plotPattern(
int x,
int y,
int pattern,
void *data);
678 static void plotPatternDarkenOnly(
int x,
int y,
int pattern,
void *data);
680 void drawDottedHLine(
int x0,
int y,
int x1);
681 void fillPattern(
Common::Rect r, uint16 pattern,
bool fillBlack =
true,
bool fillWhite =
true);
692 bool _forceMenuClosed =
false;
694 virtual int getNumColors()
const = 0;
697 uint32 getBlack()
const;
698 uint32 getWhite()
const;
705 int toMacRoman(
int unicode)
const;
707 void setPalette(
const byte *palette, uint size);
710 static void menuCallback(
int id,
Common::String &name,
void *data);
711 virtual void initialize();
712 void updateWindowManager();
719 virtual bool isVerbGuiActive()
const {
return false; }
720 virtual void reset() {}
721 virtual void resetAfterLoad() = 0;
722 virtual void update(
int delta) = 0;
724 bool runQuitDialog();
725 bool runRestartDialog();
727 virtual void setupCursor(
int &width,
int &height,
int &hotspotX,
int &hotspotY,
int &animate) = 0;
730 virtual void clearTextArea() {}
731 virtual void initTextAreaForActor(
Actor *a, byte color) {}
732 virtual void printCharToTextArea(
int chr,
int x,
int y,
int color) {}
734 MacDialogWindow *createWindow(
Common::Rect bounds, MacDialogWindowStyle style = kWindowStyleNormal, MacDialogMenuStyle menuStyle = kMenuStyleDisabled);
736 void drawBanner(
char *message);
Definition: macgui_impl.h:55
Definition: macgui_impl.h:468
TextAlign
Definition: font.h:48
Definition: macgui_impl.h:348
Definition: macgui_impl.h:332
Align the text to the left.
Definition: font.h:51
Definition: macgui_impl.h:388
Definition: macwindowmanager.h:149
Definition: macgui_impl.h:512
Definition: macgui_impl.h:538
void push_back(const T &element)
Definition: array.h:180
Definition: macgui_impl.h:580
Definition: formatinfo.h:28
size_type size() const
Definition: array.h:315
Definition: macgui_impl.h:237
Definition: macgui_impl.h:431
signed char * fill(signed char *first, signed char *last, Value val)
Definition: algorithm.h:168
Definition: macgui_impl.h:116
Definition: macgui_impl.h:444
Definition: macgui_impl.h:194