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" 43 class MacWindowManager;
58 kMSIAboutGameName = 1,
60 kMSIAreYouSureYouWantToQuit,
61 kMSIAreYouSureYouWantToRestart,
115 ParsingMethod parsingMethod;
133 virtual void onMenuOpen();
134 virtual void onMenuClose();
145 bool _paletteDirty =
false;
146 bool _suspendPaletteUpdates =
false;
148 bool _menuIsActive =
false;
149 bool _cursorWasVisible =
false;
154 int _gameFontId = -1;
156 byte _unicodeToMacRoman[96];
160 kDelayInterrupted = 1,
171 kAboutFontHeaderInside,
172 kAboutFontHeaderOutside,
174 kAboutFontHeaderSimple1,
175 kAboutFontHeaderSimple2,
179 kIndy3VerbFontRegular,
181 kIndy3VerbFontOutline,
207 enum MacDialogWindowStyle {
212 enum MacDialogMenuStyle {
218 MacGuiImpl::DelayStatus delay(uint32 ms = 0);
220 virtual bool getFontParams(FontId fontId,
int &
id,
int &size,
int &slant)
const;
226 virtual void saveScreen() {}
227 virtual void restoreScreen() {}
229 virtual void runAboutDialog() = 0;
230 virtual bool runOpenDialog(
int &saveSlotToHandle);
231 virtual bool runSaveDialog(
int &saveSlotToHandle,
Common::String &saveName);
232 virtual bool runOptionsDialog() = 0;
233 void prepareSaveLoad(
Common::StringArray &savegameNames,
bool *availSlots,
int *slotIds,
int size);
237 virtual bool readStrings();
238 void parseSTRSBlock(uint8 *strsData,
const MacSTRSParsingEntry *parsingTable,
int parsingTableSize);
248 bool setupResourceCursor(
int id,
int &width,
int &height,
int &hotspotX,
int &hotspotY,
int &animate);
254 bool _redraw =
false;
255 bool _enabled =
false;
256 bool _visible =
true;
263 bool getRedraw()
const {
return _redraw; }
264 bool isEnabled()
const {
return _enabled; }
265 bool isVisible()
const {
return _visible; }
275 MacWidgetType _type = kWidgetUnknown;
277 bool _fullRedraw =
false;
284 void drawBitmap(
Common::Rect r,
const uint16 *bitmap, uint32 color)
const;
290 void setId(
int id) { _id = id; }
291 int getId()
const {
return _id; }
293 void setType(MacWidgetType type) { _type = type; }
294 MacWidgetType getType() {
return _type; }
298 void setVisible(
bool visible) { _visible = visible; }
300 virtual void getFocus() { setRedraw(); }
301 virtual void loseFocus() { setRedraw(); }
303 virtual void setRedraw(
bool fullRedraw =
false);
305 void setEnabled(
bool enabled);
307 virtual void setValue(
int value);
308 int getValue()
const {
return _value; }
310 void rememberValue() {
314 bool valueHasChanged() {
315 return _oldValue != _value;
320 virtual bool useBeamCursor() {
return false; }
321 virtual bool findWidget(
int x,
int y)
const;
322 virtual bool reactsToKeyDown() {
return false; }
324 virtual void draw(
bool drawFocused =
false) = 0;
327 virtual bool handleDoubleClick(
Common::Event &event) {
return false; }
328 virtual bool handleMouseUp(
Common::Event &event) {
return false; }
330 virtual void handleMouseHeld() {}
331 virtual void handleWheelUp() {}
332 virtual void handleWheelDown() {}
333 virtual bool handleKeyDown(
Common::Event &event) {
return false; }
343 void hLine(
int x0,
int y0,
int x1,
bool enabled);
344 void vLine(
int x0,
int y0,
int y1,
bool enabled);
345 void drawCorners(
Common::Rect r, CornerLine *corner,
bool enabled);
350 void draw(
bool drawFocused =
false)
override;
352 bool handleMouseUp(
Common::Event &event)
override {
return true; }
362 bool findWidget(
int x,
int y)
const override;
363 void draw(
bool drawFocused =
false)
override;
376 bool _wordWrap =
true;
383 _alignment = alignment;
388 void getFocus()
override {}
389 void loseFocus()
override {}
391 void setWordWrap(
bool wordWrap) { _wordWrap = wordWrap; }
400 void setColor(uint32 fg, uint32 bg) {
401 if (fg != _fg || bg != _bg) {
408 void draw(
bool drawFocused =
false)
override;
415 uint _maxLength = 31;
422 uint32 _nextCaretBlink = 0;
423 bool _caretVisible =
true;
428 int getTextPosFromMouse(
int x,
int y);
430 void updateSelection(
int x,
int y);
431 void deleteSelection();
436 void getFocus()
override {}
437 void loseFocus()
override {}
441 bool useBeamCursor()
override {
return true; }
442 bool findWidget(
int x,
int y)
const override;
443 bool reactsToKeyDown()
override {
return true; }
445 void draw(
bool drawFocused =
false)
override;
450 void handleMouseHeld()
override;
466 void draw(
bool drawFocused =
false)
override;
476 int _grabOffset = -1;
481 int calculateValueFromPos(
int pos)
const;
482 int calculatePosFromValue(
int value)
const;
483 int calculateValueFromPos()
const;
484 int calculatePosFromValue()
const;
488 :
MacWidget(window, bounds,
"SliderBase", enabled),
489 _minValue(minValue), _maxValue(maxValue),
490 _minPos(minPos), _maxPos(maxPos) {}
497 void getFocus()
override {}
498 void loseFocus()
override {}
500 int getMinValue()
const {
return _minValue; }
501 int getMaxValue()
const {
return _maxValue; }
502 void setValue(
int value)
override;
504 void addStop(
int pos,
int value) {
505 _posToValue[pos] = value;
506 _valueToPos[value] = pos;
513 uint32 _nextRepeat = 0;
518 bool _upArrowPressed =
false;
519 bool _downArrowPressed =
false;
529 void drawUpArrow(
bool markAsDirty);
530 void drawDownArrow(
bool markAsDirty);
531 void drawArrow(
Common::Rect r,
const uint16 *bitmap,
bool markAsDirty);
533 void eraseDragHandle();
539 bool isScrollable()
const {
return (_maxValue - _minValue) > 0; }
540 int getPageSize()
const {
return _pageSize; }
542 bool findWidget(
int x,
int y)
const override;
543 void draw(
bool drawFocued =
false)
override;
544 void redrawHandle(
int oldValue,
int newValue);
549 void handleMouseHeld()
override;
550 void handleWheelUp()
override;
551 void handleWheelDown()
override;
560 bool _freeBackground =
false;
561 bool _snapWhileDragging =
false;
568 :
MacSliderBase(window, background->getBounds(), minValue, maxValue, minX + leftMargin, maxX - rightMargin, enabled),
569 _background(background->getImage()), _handle(handle), _minX(minX), _maxX(maxX) {}
573 void setValue(
int value)
override;
575 bool findWidget(
int x,
int y)
const override;
576 void draw(
bool drawFocused =
false)
override;
578 void setSnapWhileDragging(
bool snap) { _snapWhileDragging = snap; }
583 void handleWheelUp()
override;
584 void handleWheelDown()
override;
592 bool _sliderFocused =
false;
595 void handleWheel(
int distance);
601 void getFocus()
override {}
602 void loseFocus()
override {}
604 void setValue(
int value)
override {
605 if (value != _value) {
611 bool findWidget(
int x,
int y)
const override;
612 void setRedraw(
bool fullRedraw =
false)
override;
613 void draw(
bool drawFocused =
false)
override;
619 void handleMouseHeld()
override;
620 void handleWheelUp()
override;
621 void handleWheelDown()
override;
629 bool _menuVisible =
false;
638 bool findWidget(
int x,
int y)
const override;
639 void draw(
bool drawFocused =
false)
override;
646 enum MacDialogEventType {
654 MacDialogEventType type;
663 bool _shakeWasEnabled;
668 bool _visible =
false;
670 uint32 _lastClickTime = 0;
675 bool _cursorWasVisible =
false;
676 bool _beamCursorVisible =
false;
677 const int _beamCursorHotspotX = 3;
678 const int _beamCursorHotspotY = 4;
680 void drawBeamCursor();
681 void undrawBeamCursor();
702 bool _dirtyPalette =
false;
708 void addWidget(
MacWidget *widget, MacWidgetType type);
720 bool isVisible()
const {
return _visible; }
724 void delayAndUpdate();
727 uint getNumWidgets()
const {
return _widgets.
size(); }
730 MacWidget *getWidget(MacWidgetType type, uint nr = 0)
const;
732 void setDefaultWidget(
MacWidget *widget) { _defaultWidget = widget; }
733 MacWidget *getDefaultWidget()
const {
return _defaultWidget; }
735 void setFocusedWidget(
int x,
int y);
736 void clearFocusedWidget();
737 MacWidget *getFocusedWidget()
const {
return _focusedWidget; }
741 int findWidget(
int x,
int y)
const;
750 MacGuiImpl::MacSlider *addSlider(
int x,
int y,
int h,
int minValue,
int maxValue,
int pageSize,
bool enabled);
751 MacGuiImpl::MacImageSlider *addImageSlider(
int backgroundId,
int handleId,
bool enabled,
int minX,
int maxX,
int minValue,
int maxValue,
int leftMargin = 0,
int rightMargin = 0);
759 void replaceSubstitution(
int nr,
Common::String text) { _substitutions[nr] = text; }
761 bool hasSubstitution(uint n)
const {
return n < _substitutions.
size(); }
762 Common::String &getSubstitution(uint n) {
return _substitutions[n]; }
765 void update(
bool fullRedraw =
false);
767 void drawPatternRoundRect(
const Common::Rect &rect,
int arc, uint32 color,
bool filled,
bool darkenOnly);
769 void drawDottedHLine(
int x0,
int y,
int x1);
770 void fillPattern(
Common::Rect r, uint16 pattern,
bool fillBlack =
true,
bool fillWhite =
true);
771 void drawSprite(
const MacImage *image,
int x,
int y);
783 virtual int getNumColors()
const = 0;
786 virtual uint32 getBlack()
const;
787 virtual uint32 getWhite()
const;
797 int toMacRoman(
int unicode)
const;
799 void setPaletteDirty();
800 void updatePalette();
804 static void menuCallback(
int id,
Common::String &name,
void *data);
805 virtual bool initialize();
806 virtual void updateWindowManager();
807 virtual void updateMenus();
815 virtual bool isVerbGuiActive()
const {
return false; }
816 virtual void reset() {}
817 virtual void resetAfterLoad() = 0;
818 virtual void update(
int delta) = 0;
820 virtual bool runQuitDialog();
821 virtual bool runRestartDialog();
823 virtual void setupCursor(
int &width,
int &height,
int &hotspotX,
int &hotspotY,
int &animate) = 0;
826 virtual void clearTextArea() {}
827 virtual void initTextAreaForActor(
Actor *a, byte color) {}
828 virtual void printCharToTextArea(
int chr,
int x,
int y,
int color) {}
832 MacDialogWindow *createWindow(
Common::Rect bounds, MacDialogWindowStyle style = kWindowStyleNormal, MacDialogMenuStyle menuStyle = kMenuStyleDisabled);
835 void drawBanner(
char *message);
void clear(bool shrinkArray=0)
Definition: hashmap.h:427
Definition: macgui_impl.h:52
Definition: macgui_impl.h:510
TextAlign
Definition: font.h:48
Definition: macgui_impl.h:371
Definition: macgui_impl.h:355
Definition: macgui_impl.h:652
Definition: macgui_impl.h:554
Align the text to the left.
Definition: font.h:51
Definition: macgui_impl.h:411
Definition: macwindowmanager.h:147
Definition: macgui_impl.h:454
Definition: macgui_impl.h:587
void push_back(const T &element)
Definition: array.h:183
Definition: macgui_impl.h:657
Definition: formatinfo.h:28
size_type size() const
Definition: array.h:318
Definition: macgui_impl.h:251
signed char * fill(signed char *first, signed char *last, Value val)
Definition: algorithm.h:168
Definition: macgui_impl.h:113
Simple class for handling a palette data.
Definition: palette.h:55
Definition: macgui_impl.h:469
Definition: macgui_impl.h:199
Definition: atari-screen.h:42