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);
252 bool _redraw =
false;
253 bool _enabled =
false;
254 bool _visible =
true;
261 bool getRedraw()
const {
return _redraw; }
262 bool isEnabled()
const {
return _enabled; }
263 bool isVisible()
const {
return _visible; }
273 MacWidgetType _type = kWidgetUnknown;
275 bool _fullRedraw =
false;
282 void drawBitmap(
Common::Rect r,
const uint16 *bitmap, uint32 color)
const;
288 void setId(
int id) { _id = id; }
289 int getId()
const {
return _id; }
291 void setType(MacWidgetType type) { _type = type; }
292 MacWidgetType getType() {
return _type; }
296 void setVisible(
bool visible) { _visible = visible; }
298 virtual void getFocus() { setRedraw(); }
299 virtual void loseFocus() { setRedraw(); }
301 virtual void setRedraw(
bool fullRedraw =
false);
303 void setEnabled(
bool enabled);
305 virtual void setValue(
int value);
306 int getValue()
const {
return _value; }
308 void rememberValue() {
312 bool valueHasChanged() {
313 return _oldValue != _value;
318 virtual bool useBeamCursor() {
return false; }
319 virtual bool findWidget(
int x,
int y)
const;
320 virtual bool reactsToKeyDown() {
return false; }
322 virtual void draw(
bool drawFocused =
false) = 0;
325 virtual bool handleDoubleClick(
Common::Event &event) {
return false; }
326 virtual bool handleMouseUp(
Common::Event &event) {
return false; }
328 virtual void handleMouseHeld() {}
329 virtual void handleWheelUp() {}
330 virtual void handleWheelDown() {}
331 virtual bool handleKeyDown(
Common::Event &event) {
return false; }
341 void hLine(
int x0,
int y0,
int x1,
bool enabled);
342 void vLine(
int x0,
int y0,
int y1,
bool enabled);
343 void drawCorners(
Common::Rect r, CornerLine *corner,
bool enabled);
348 void draw(
bool drawFocused =
false)
override;
350 bool handleMouseUp(
Common::Event &event)
override {
return true; }
360 bool findWidget(
int x,
int y)
const override;
361 void draw(
bool drawFocused =
false)
override;
374 bool _wordWrap =
true;
381 _alignment = alignment;
386 void getFocus()
override {}
387 void loseFocus()
override {}
389 void setWordWrap(
bool wordWrap) { _wordWrap = wordWrap; }
398 void setColor(uint32 fg, uint32 bg) {
399 if (fg != _fg || bg != _bg) {
406 void draw(
bool drawFocused =
false)
override;
413 uint _maxLength = 31;
420 uint32 _nextCaretBlink = 0;
421 bool _caretVisible =
true;
426 int getTextPosFromMouse(
int x,
int y);
428 void updateSelection(
int x,
int y);
429 void deleteSelection();
434 void getFocus()
override {}
435 void loseFocus()
override {}
439 bool useBeamCursor()
override {
return true; }
440 bool findWidget(
int x,
int y)
const override;
441 bool reactsToKeyDown()
override {
return true; }
443 void draw(
bool drawFocused =
false)
override;
448 void handleMouseHeld()
override;
464 void draw(
bool drawFocused =
false)
override;
474 int _grabOffset = -1;
479 int calculateValueFromPos(
int pos)
const;
480 int calculatePosFromValue(
int value)
const;
481 int calculateValueFromPos()
const;
482 int calculatePosFromValue()
const;
486 :
MacWidget(window, bounds,
"SliderBase", enabled),
487 _minValue(minValue), _maxValue(maxValue),
488 _minPos(minPos), _maxPos(maxPos) {}
495 void getFocus()
override {}
496 void loseFocus()
override {}
498 int getMinValue()
const {
return _minValue; }
499 int getMaxValue()
const {
return _maxValue; }
500 void setValue(
int value)
override;
502 void addStop(
int pos,
int value) {
503 _posToValue[pos] = value;
504 _valueToPos[value] = pos;
511 uint32 _nextRepeat = 0;
516 bool _upArrowPressed =
false;
517 bool _downArrowPressed =
false;
527 void drawUpArrow(
bool markAsDirty);
528 void drawDownArrow(
bool markAsDirty);
529 void drawArrow(
Common::Rect r,
const uint16 *bitmap,
bool markAsDirty);
531 void eraseDragHandle();
537 bool isScrollable()
const {
return (_maxValue - _minValue) > 0; }
538 int getPageSize()
const {
return _pageSize; }
540 bool findWidget(
int x,
int y)
const override;
541 void draw(
bool drawFocued =
false)
override;
542 void redrawHandle(
int oldValue,
int newValue);
547 void handleMouseHeld()
override;
548 void handleWheelUp()
override;
549 void handleWheelDown()
override;
558 bool _freeBackground =
false;
559 bool _snapWhileDragging =
false;
566 :
MacSliderBase(window, background->getBounds(), minValue, maxValue, minX + leftMargin, maxX - rightMargin, enabled),
567 _background(background->getImage()), _handle(handle), _minX(minX), _maxX(maxX) {}
571 void setValue(
int value)
override;
573 bool findWidget(
int x,
int y)
const override;
574 void draw(
bool drawFocused =
false)
override;
576 void setSnapWhileDragging(
bool snap) { _snapWhileDragging = snap; }
581 void handleWheelUp()
override;
582 void handleWheelDown()
override;
590 bool _sliderFocused =
false;
593 void handleWheel(
int distance);
599 void getFocus()
override {}
600 void loseFocus()
override {}
602 void setValue(
int value)
override {
603 if (value != _value) {
609 bool findWidget(
int x,
int y)
const override;
610 void setRedraw(
bool fullRedraw =
false)
override;
611 void draw(
bool drawFocused =
false)
override;
617 void handleMouseHeld()
override;
618 void handleWheelUp()
override;
619 void handleWheelDown()
override;
627 bool _menuVisible =
false;
636 bool findWidget(
int x,
int y)
const override;
637 void draw(
bool drawFocused =
false)
override;
644 enum MacDialogEventType {
652 MacDialogEventType type;
661 bool _shakeWasEnabled;
666 bool _visible =
false;
668 uint32 _lastClickTime = 0;
673 bool _cursorWasVisible =
false;
674 bool _beamCursorVisible =
false;
675 const int _beamCursorHotspotX = 3;
676 const int _beamCursorHotspotY = 4;
678 void drawBeamCursor();
679 void undrawBeamCursor();
700 bool _dirtyPalette =
false;
706 void addWidget(
MacWidget *widget, MacWidgetType type);
718 bool isVisible()
const {
return _visible; }
722 void delayAndUpdate();
725 uint getNumWidgets()
const {
return _widgets.
size(); }
728 MacWidget *getWidget(MacWidgetType type, uint nr = 0)
const;
730 void setDefaultWidget(
MacWidget *widget) { _defaultWidget = widget; }
731 MacWidget *getDefaultWidget()
const {
return _defaultWidget; }
733 void setFocusedWidget(
int x,
int y);
734 void clearFocusedWidget();
735 MacWidget *getFocusedWidget()
const {
return _focusedWidget; }
739 int findWidget(
int x,
int y)
const;
748 MacGuiImpl::MacSlider *addSlider(
int x,
int y,
int h,
int minValue,
int maxValue,
int pageSize,
bool enabled);
749 MacGuiImpl::MacImageSlider *addImageSlider(
int backgroundId,
int handleId,
bool enabled,
int minX,
int maxX,
int minValue,
int maxValue,
int leftMargin = 0,
int rightMargin = 0);
757 void replaceSubstitution(
int nr,
Common::String text) { _substitutions[nr] = text; }
759 bool hasSubstitution(uint n)
const {
return n < _substitutions.
size(); }
760 Common::String &getSubstitution(uint n) {
return _substitutions[n]; }
763 void update(
bool fullRedraw =
false);
765 void drawPatternRoundRect(
const Common::Rect &rect,
int arc, uint32 color,
bool filled,
bool darkenOnly);
767 void drawDottedHLine(
int x0,
int y,
int x1);
768 void fillPattern(
Common::Rect r, uint16 pattern,
bool fillBlack =
true,
bool fillWhite =
true);
769 void drawSprite(
const MacImage *image,
int x,
int y);
781 virtual int getNumColors()
const = 0;
784 virtual uint32 getBlack()
const;
785 virtual uint32 getWhite()
const;
795 int toMacRoman(
int unicode)
const;
797 void setPaletteDirty();
798 void updatePalette();
802 static void menuCallback(
int id,
Common::String &name,
void *data);
803 virtual bool initialize();
804 void updateWindowManager();
805 virtual void updateMenus();
813 virtual bool isVerbGuiActive()
const {
return false; }
814 virtual void reset() {}
815 virtual void resetAfterLoad() = 0;
816 virtual void update(
int delta) = 0;
818 virtual bool runQuitDialog();
819 virtual bool runRestartDialog();
821 virtual void setupCursor(
int &width,
int &height,
int &hotspotX,
int &hotspotY,
int &animate) = 0;
824 virtual void clearTextArea() {}
825 virtual void initTextAreaForActor(
Actor *a, byte color) {}
826 virtual void printCharToTextArea(
int chr,
int x,
int y,
int color) {}
830 MacDialogWindow *createWindow(
Common::Rect bounds, MacDialogWindowStyle style = kWindowStyleNormal, MacDialogMenuStyle menuStyle = kMenuStyleDisabled);
833 void drawBanner(
char *message);
void clear(bool shrinkArray=0)
Definition: hashmap.h:427
Definition: macgui_impl.h:52
Definition: macgui_impl.h:508
TextAlign
Definition: font.h:48
Definition: macgui_impl.h:369
Definition: macgui_impl.h:353
Definition: macgui_impl.h:650
Definition: macgui_impl.h:552
Align the text to the left.
Definition: font.h:51
Definition: macgui_impl.h:409
Definition: macwindowmanager.h:147
Definition: macgui_impl.h:452
Definition: macgui_impl.h:585
void push_back(const T &element)
Definition: array.h:180
Definition: macgui_impl.h:655
Definition: formatinfo.h:28
size_type size() const
Definition: array.h:315
Definition: macgui_impl.h:249
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:51
Definition: macgui_impl.h:467
Definition: macgui_impl.h:199
Definition: atari-screen.h:44