ScummVM API documentation
macgui_impl.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef SCUMM_MACGUI_MACGUI_IMPL_H
23 #define SCUMM_MACGUI_MACGUI_IMPL_H
24 
25 #define TEXT_END_MARKER { 0, 0, kStyleRegular, Graphics::kTextAlignLeft, nullptr }
26 
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"
32 
33 #include "engines/engine.h"
34 
35 #include "graphics/font.h"
36 #include "graphics/surface.h"
37 
38 class OSystem;
39 
40 namespace Graphics {
41 struct Surface;
42 class Palette;
43 class MacWindowManager;
44 class MacMenu;
45 }
46 
47 namespace Scumm {
48 
49 class ScummEngine;
50 class Actor;
51 
52 class MacGuiImpl {
53 public:
54  class MacDialogWindow;
55 
56  enum MacStringIds {
57  kMSISkip = -1,
58  kMSIAboutGameName = 1,
59  kMSIRoughCommandMsg,
60  kMSIAreYouSureYouWantToQuit,
61  kMSIAreYouSureYouWantToRestart,
62  kMSIGameName,
63  kMSIOpenGameFile,
64  kMSISaveGameFileAs,
65  kMSIGameFile,
66  kMSIAboutString1,
67  kMSIAboutString2,
68  kMSIAboutString3,
69  kMSIAboutString4,
70  kMSIAboutString5,
71  kMSIAboutString6,
72  kMSIAboutString7,
73  kMSIAboutString8,
74  kMSIAboutString9,
75  kMSIAboutString10,
76  kMSIAboutString11,
77  kMSIAboutString12,
78  kMSIAboutString13,
79  kMSIAboutString14,
80  kMSIAboutString15,
81  kMSIAboutString16,
82  kMSIAboutString17,
83  kMSIAboutString18,
84  kMSIAboutString19,
85  kMSIAboutString20,
86  kMSIAboutString21,
87  kMSIAboutString22,
88  kMSIAboutString23,
89  kMSIAboutString24,
90  kMSIAboutString25,
91  kMSIAboutString26,
92  kMSIAboutString27,
93  kMSIAboutString28,
94  kMSIAboutString29,
95  kMSIAboutString30,
96  kMSIAboutString31,
97  kMSIAboutString32,
98  kMSIAboutString33,
99  kMSIAboutString34,
100  kMSIAboutString35,
101  kMSIAboutString36,
102  kMSIAboutString37,
103  kMSIAboutString38,
104  kMSIAboutString39,
105  kMSIAboutString40
106  };
107 
108  enum ParsingMethod {
109  kStrC,
110  kStrPascal,
111  };
112 
114  MacStringIds strId;
115  ParsingMethod parsingMethod;
116  int numStrings;
117  };
118 
119  enum MacWidgetType {
120  kWidgetUnknown,
121  kWidgetButton,
122  kWidgetCheckbox,
123  kWidgetStaticText,
124  kWidgetEditText,
125  kWidgetIcon,
126  kWidgetImage,
127  kWidgetSlider,
128  kWidgetListBox,
129  kWidgetImageSlider,
130  kWidgetPopUpMenu
131  };
132 
133  virtual void onMenuOpen();
134  virtual void onMenuClose();
135 
136 protected:
137  ScummEngine *_vm = nullptr;
138  OSystem *_system = nullptr;
139 
140  Graphics::Surface *_surface = nullptr;
141  MacGuiImpl::MacDialogWindow *_bannerWindow = nullptr;
142 
143  Common::Path _resourceFile;
144 
145  bool _paletteDirty = false;
146  bool _suspendPaletteUpdates = false;
147 
148  bool _menuIsActive = false;
149  bool _cursorWasVisible = false;
150 
152  Common::Array<Common::String> _strsStrings;
153 
154  int _gameFontId = -1;
155 
156  byte _unicodeToMacRoman[96];
157 
158  enum DelayStatus {
159  kDelayDone = 0,
160  kDelayInterrupted = 1,
161  kDelayAborted
162  };
163 
164  enum FontId {
165  kSystemFont,
166 
167  kAboutFontRegular,
168  kAboutFontBold,
169  kAboutFontBold2,
170  kAboutFontExtraBold,
171  kAboutFontHeaderInside,
172  kAboutFontHeaderOutside,
173  kAboutFontHeader,
174  kAboutFontHeaderSimple1,
175  kAboutFontHeaderSimple2,
176 
177  kIndy3FontSmall,
178  kIndy3FontMedium,
179  kIndy3VerbFontRegular,
180  kIndy3VerbFontBold,
181  kIndy3VerbFontOutline,
182 
183  kLoomFontSmall,
184  kLoomFontMedium,
185  kLoomFontLarge
186  };
187 
188  enum TextStyle {
189  kStyleHeader1,
190  kStyleHeader2,
191  kStyleHeaderSimple1,
192  kStyleHeaderSimple2,
193  kStyleBold,
194  kStyleBold2,
195  kStyleExtraBold,
196  kStyleRegular
197  };
198 
199  struct TextLine {
200  int x;
201  int y;
202  TextStyle style;
203  Graphics::TextAlign align;
204  const char *str;
205  };
206 
207  enum MacDialogWindowStyle {
208  kWindowStyleNormal,
209  kWindowStyleRounded
210  };
211 
212  enum MacDialogMenuStyle {
213  kMenuStyleNone,
214  kMenuStyleDisabled,
215  kMenuStyleApple
216  };
217 
218  MacGuiImpl::DelayStatus delay(uint32 ms = 0);
219 
220  virtual bool getFontParams(FontId fontId, int &id, int &size, int &slant) const;
221 
222  virtual bool handleMenu(int id, Common::String &name);
223 
224  // For older games, there is no problem with displaying the Mac GUI and
225  // the game at the same time. For newer, there is.
226  virtual void saveScreen() {}
227  virtual void restoreScreen() {}
228 
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);
234 
235  bool runOkCancelDialog(Common::String text);
236 
237  virtual bool readStrings();
238  void parseSTRSBlock(uint8 *strsData, const MacSTRSParsingEntry *parsingTable, int parsingTableSize);
239 
240  void addMenu(Graphics::MacMenu *menu, int menuId);
241 
242  // These are non interactable, no point in having them as widgets for now...
243  void drawFakePathList(MacDialogWindow *window, Common::Rect r, const char *text);
244  void drawFakeDriveLabel(MacDialogWindow *window, Common::Rect r, const char *text);
245 
246  Graphics::Surface *createRemappedSurface(const Graphics::Surface *surface, const byte *palette, uint colorCount);
247 
248  bool setupResourceCursor(int id, int &width, int &height, int &hotspotX, int &hotspotY, int &animate);
249 
250 public:
251  class MacGuiObject {
252  protected:
253  Common::Rect _bounds;
254  bool _redraw = false;
255  bool _enabled = false;
256  bool _visible = true;
257 
258  public:
259  MacGuiObject(Common::Rect bounds, bool enabled) : _bounds(bounds), _enabled(enabled) {}
260  virtual ~MacGuiObject() {}
261 
262  Common::Rect getBounds() const { return _bounds; }
263  bool getRedraw() const { return _redraw; }
264  bool isEnabled() const { return _enabled; }
265  bool isVisible() const { return _visible; }
266  };
267 
268  class MacWidget : public MacGuiObject {
269  protected:
271  uint32 _black;
272  uint32 _white;
273 
274  int _id = -1;
275  MacWidgetType _type = kWidgetUnknown;
276 
277  bool _fullRedraw = false;
278 
279  Common::String _text;
280  int _oldValue = 0;
281  int _value = 0;
282 
283  int drawText(Common::String text, int x, int y, int w, uint32 fg = 0, uint32 bg = 0, Graphics::TextAlign align = Graphics::kTextAlignLeft, bool wordWrap = false, int deltax = 0) const;
284  void drawBitmap(Common::Rect r, const uint16 *bitmap, uint32 color) const;
285 
286  public:
287  MacWidget(MacGuiImpl::MacDialogWindow *window, Common::Rect bounds, Common::String text, bool enabled);
288  virtual ~MacWidget() {};
289 
290  void setId(int id) { _id = id; }
291  int getId() const { return _id; }
292 
293  void setType(MacWidgetType type) { _type = type; }
294  MacWidgetType getType() { return _type; }
295 
296  // Visibility never changes after initialization, so it does
297  // not trigger a redraw.
298  void setVisible(bool visible) { _visible = visible; }
299 
300  virtual void getFocus() { setRedraw(); }
301  virtual void loseFocus() { setRedraw(); }
302 
303  virtual void setRedraw(bool fullRedraw = false);
304 
305  void setEnabled(bool enabled);
306 
307  virtual void setValue(int value);
308  int getValue() const { return _value; }
309 
310  void rememberValue() {
311  _oldValue = _value;
312  }
313 
314  bool valueHasChanged() {
315  return _oldValue != _value;
316  }
317 
318  Common::String getText() const;
319 
320  virtual bool useBeamCursor() { return false; }
321  virtual bool findWidget(int x, int y) const;
322  virtual bool reactsToKeyDown() { return false; }
323 
324  virtual void draw(bool drawFocused = false) = 0;
325 
326  virtual void handleMouseDown(Common::Event &event) {}
327  virtual bool handleDoubleClick(Common::Event &event) { return false; }
328  virtual bool handleMouseUp(Common::Event &event) { return false; }
329  virtual void handleMouseMove(Common::Event &event) {}
330  virtual void handleMouseHeld() {}
331  virtual void handleWheelUp() {}
332  virtual void handleWheelDown() {}
333  virtual bool handleKeyDown(Common::Event &event) { return false; }
334  };
335 
336  class MacButton : public MacWidget {
337  private:
338  struct CornerLine {
339  int start;
340  int length;
341  };
342 
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);
346 
347  public:
348  MacButton(MacGuiImpl::MacDialogWindow *window, Common::Rect bounds, Common::String text, bool enabled) : MacWidget(window, bounds, text, enabled) {}
349 
350  void draw(bool drawFocused = false) override;
351 
352  bool handleMouseUp(Common::Event &event) override { return true; }
353  };
354 
355  class MacCheckbox : public MacWidget {
356  private:
357  Common::Rect _hitBounds;
358 
359  public:
360  MacCheckbox(MacGuiImpl::MacDialogWindow *window, Common::Rect bounds, Common::String text, bool enabled);
361 
362  bool findWidget(int x, int y) const override;
363  void draw(bool drawFocused = false) override;
364  bool handleMouseUp(Common::Event &event) override;
365  };
366 
367  // The dialogs add texts as disabled, but we don't want it to be drawn
368  // as disabled so we enable it and make it "disabled" by giving it a
369  // custom findWidget().
370 
371  class MacStaticText : public MacWidget {
372  private:
373  uint32 _fg;
374  uint32 _bg;
376  bool _wordWrap = true;
377 
378  public:
381  Common::Rect bounds, Common::String text,
382  bool enabled, Graphics::TextAlign alignment = Graphics::kTextAlignLeft) : MacWidget(window, bounds, text, true) {
383  _alignment = alignment;
384  _fg = _black;
385  _bg = _white;
386  }
387 
388  void getFocus() override {}
389  void loseFocus() override {}
390 
391  void setWordWrap(bool wordWrap) { _wordWrap = wordWrap; }
392 
393  void setText(Common::String text) {
394  if (text != _text) {
395  _text = text;
396  setRedraw();
397  }
398  }
399 
400  void setColor(uint32 fg, uint32 bg) {
401  if (fg != _fg || bg != _bg) {
402  _fg = fg;
403  _bg = bg;
404  setRedraw();
405  }
406  }
407 
408  void draw(bool drawFocused = false) override;
409  };
410 
411  class MacEditText : public MacWidget {
412  private:
413  // Max length of a SCUMM saved game name. We could make this
414  // configurable later, if needed.
415  uint _maxLength = 31;
416 
417  int _textPos = 1;
418  int _selectLen = 0;
419  int _caretPos = 0;
420  int _caretX = -1;
421 
422  uint32 _nextCaretBlink = 0;
423  bool _caretVisible = true;
424 
425  const Graphics::Font *_font;
426  Graphics::Surface _textSurface;
427 
428  int getTextPosFromMouse(int x, int y);
429 
430  void updateSelection(int x, int y);
431  void deleteSelection();
432 
433  public:
434  MacEditText(MacGuiImpl::MacDialogWindow *window, Common::Rect bounds, Common::String text, bool enabled);
435 
436  void getFocus() override {}
437  void loseFocus() override {}
438 
439  void selectAll();
440 
441  bool useBeamCursor() override { return true; }
442  bool findWidget(int x, int y) const override;
443  bool reactsToKeyDown() override { return true; }
444 
445  void draw(bool drawFocused = false) override;
446 
447  void handleMouseDown(Common::Event &event) override;
448  bool handleDoubleClick(Common::Event &event) override;
449  bool handleKeyDown(Common::Event &event) override;
450  void handleMouseHeld() override;
451  void handleMouseMove(Common::Event &event) override;
452  };
453 
454  class MacImage : public MacWidget {
455  private:
456  Graphics::Surface *_image = nullptr;
457  Graphics::Surface *_mask = nullptr;
458 
459  public:
460  MacImage(MacGuiImpl::MacDialogWindow *window, Common::Rect bounds, Graphics::Surface *surface, Graphics::Surface *mask, bool enabled);
461  ~MacImage();
462 
463  Graphics::Surface *getImage() const { return _image; }
464  Graphics::Surface *getMask() const { return _mask; }
465 
466  void draw(bool drawFocused = false) override;
467  };
468 
469  class MacSliderBase : public MacWidget {
470  protected:
471  int _minValue;
472  int _maxValue;
473  int _minPos;
474  int _maxPos;
475  int _handlePos = -1;
476  int _grabOffset = -1;
477 
478  Common::HashMap<int, int> _posToValue;
479  Common::HashMap<int, int> _valueToPos;
480 
481  int calculateValueFromPos(int pos) const;
482  int calculatePosFromValue(int value) const;
483  int calculateValueFromPos() const;
484  int calculatePosFromValue() const;
485 
486  public:
487  MacSliderBase(MacGuiImpl::MacDialogWindow *window, Common::Rect bounds, int minValue, int maxValue, int minPos, int maxPos, bool enabled)
488  : MacWidget(window, bounds, "SliderBase", enabled),
489  _minValue(minValue), _maxValue(maxValue),
490  _minPos(minPos), _maxPos(maxPos) {}
491 
492  virtual ~MacSliderBase() {
493  _posToValue.clear();
494  _valueToPos.clear();
495  }
496 
497  void getFocus() override {}
498  void loseFocus() override {}
499 
500  int getMinValue() const { return _minValue; }
501  int getMaxValue() const { return _maxValue; }
502  void setValue(int value) override;
503 
504  void addStop(int pos, int value) {
505  _posToValue[pos] = value;
506  _valueToPos[value] = pos;
507  }
508  };
509 
510  class MacSlider : public MacSliderBase {
511  private:
512  Common::Point _clickPos;
513  uint32 _nextRepeat = 0;
514 
515  int _pageSize = 0;
516  int _paging = 0;
517 
518  bool _upArrowPressed = false;
519  bool _downArrowPressed = false;
520 
521  Common::Rect _boundsButtonUp;
522  Common::Rect _boundsButtonDown;
523  Common::Rect _boundsBody;
524 
525  Common::Rect getHandleRect(int value);
526 
527  void fill(Common::Rect r, bool inverted = false);
528 
529  void drawUpArrow(bool markAsDirty);
530  void drawDownArrow(bool markAsDirty);
531  void drawArrow(Common::Rect r, const uint16 *bitmap, bool markAsDirty);
532 
533  void eraseDragHandle();
534  void drawHandle(Common::Rect r);
535 
536  public:
537  MacSlider(MacGuiImpl::MacDialogWindow *window, Common::Rect bounds, int minValue, int maxValue, int pageSize, bool enabled);
538 
539  bool isScrollable() const { return (_maxValue - _minValue) > 0; }
540  int getPageSize() const { return _pageSize; }
541 
542  bool findWidget(int x, int y) const override;
543  void draw(bool drawFocued = false) override;
544  void redrawHandle(int oldValue, int newValue);
545 
546  void handleMouseDown(Common::Event &event) override;
547  bool handleMouseUp(Common::Event &event) override;
548  void handleMouseMove(Common::Event &event) override;
549  void handleMouseHeld() override;
550  void handleWheelUp() override;
551  void handleWheelDown() override;
552  };
553 
554  class MacImageSlider : public MacSliderBase {
555  private:
556  Graphics::Surface *_background;
557  MacImage *_handle;
558  int _minX;
559  int _maxX;
560  bool _freeBackground = false;
561  bool _snapWhileDragging = false;
562 
563  void eraseHandle();
564  void drawHandle();
565 
566  public:
567  MacImageSlider(MacGuiImpl::MacDialogWindow *window, MacImage *background, MacImage *handle, bool enabled, int minX, int maxX, int minValue, int maxValue, int leftMargin, int rightMargin)
568  : MacSliderBase(window, background->getBounds(), minValue, maxValue, minX + leftMargin, maxX - rightMargin, enabled),
569  _background(background->getImage()), _handle(handle), _minX(minX), _maxX(maxX) {}
570  MacImageSlider(MacGuiImpl::MacDialogWindow *window, Common::Rect bounds, MacImage *handle, bool enabled, int minX, int maxX, int minValue, int maxValue);
571  ~MacImageSlider();
572 
573  void setValue(int value) override;
574 
575  bool findWidget(int x, int y) const override;
576  void draw(bool drawFocused = false) override;
577 
578  void setSnapWhileDragging(bool snap) { _snapWhileDragging = snap; }
579 
580  void handleMouseDown(Common::Event &event) override;
581  bool handleMouseUp(Common::Event &event) override;
582  void handleMouseMove(Common::Event &event) override;
583  void handleWheelUp() override;
584  void handleWheelDown() override;
585  };
586 
587  class MacListBox : public MacWidget {
588  private:
589  Common::StringArray _texts;
590  Common::Array<MacStaticText *> _textWidgets;
591  MacSlider *_slider;
592  bool _sliderFocused = false;
593 
594  void updateTexts();
595  void handleWheel(int distance);
596 
597  public:
598  MacListBox(MacGuiImpl::MacDialogWindow *window, Common::Rect bounds, Common::StringArray texts, bool enabled, bool contentUntouchable = true);
599  ~MacListBox();
600 
601  void getFocus() override {}
602  void loseFocus() override {}
603 
604  void setValue(int value) override {
605  if (value != _value) {
606  _value = value;
607  updateTexts();
608  }
609  }
610 
611  bool findWidget(int x, int y) const override;
612  void setRedraw(bool fullRedraw = false) override;
613  void draw(bool drawFocused = false) override;
614 
615  void handleMouseDown(Common::Event &event) override;
616  bool handleDoubleClick(Common::Event &event) override;
617  bool handleMouseUp(Common::Event &event) override;
618  void handleMouseMove(Common::Event &event) override;
619  void handleMouseHeld() override;
620  void handleWheelUp() override;
621  void handleWheelDown() override;
622  bool handleKeyDown(Common::Event &event) override;
623  };
624 
625  class MacPopUpMenu : public MacWidget {
626  private:
627  Common::StringArray _texts;
628  int _textWidth;
629  bool _menuVisible = false;
630  int _selected;
631  Graphics::Surface _popUpBackground;
632  Common::Rect _popUpBounds;
633 
634  public:
635  MacPopUpMenu(MacGuiImpl::MacDialogWindow *window, Common::Rect bounds, Common::String text, int textWidth, Common::StringArray texts, bool enabled);
636  ~MacPopUpMenu();
637 
638  bool findWidget(int x, int y) const override;
639  void draw(bool drawFocused = false) override;
640 
641  void handleMouseDown(Common::Event &event) override;
642  bool handleMouseUp(Common::Event &event) override;
643  void handleMouseMove(Common::Event &event) override;
644  };
645 
646  enum MacDialogEventType {
647  kDialogClick,
648  kDialogValueChange,
649  kDialogKeyDown
650  };
651 
652  struct MacDialogEvent {
653  MacWidget *widget;
654  MacDialogEventType type;
655  };
656 
658  private:
659  Common::Queue<MacDialogEvent> _eventQueue;
660  uint32 _black;
661  uint32 _white;
662 
663  bool _shakeWasEnabled;
664 
665  Common::Rect _bounds;
666  int _margin;
667 
668  bool _visible = false;
669 
670  uint32 _lastClickTime = 0;
671  Common::Point _lastClickPos;
672 
673  Graphics::Surface *_beamCursor = nullptr;
674  Common::Point _beamCursorPos;
675  bool _cursorWasVisible = false;
676  bool _beamCursorVisible = false;
677  const int _beamCursorHotspotX = 3;
678  const int _beamCursorHotspotY = 4;
679 
680  void drawBeamCursor();
681  void undrawBeamCursor();
682 
683  PauseToken _pauseToken;
684 
685  Graphics::Surface *_from = nullptr;
686  Graphics::Surface *_backup = nullptr;
687  Graphics::Surface _surface;
688  Graphics::Surface _innerSurface;
689 
691 
692  MacWidget *_defaultWidget = nullptr;
693 
694  MacWidget *_focusedWidget = nullptr;
695  Common::Point _focusClick;
696  Common::Point _oldMousePos;
697  Common::Point _mousePos;
698  Common::Point _realMousePos;
699 
700  Common::StringArray _substitutions;
701  Common::Array<Common::Rect> _dirtyRects;
702  bool _dirtyPalette = false;
703 
704  void queueEvent(MacGuiImpl::MacWidget *widget, MacGuiImpl::MacDialogEventType type);
705 
706  void copyToScreen(Graphics::Surface *s = nullptr) const;
707 
708  void addWidget(MacWidget *widget, MacWidgetType type);
709 
710  public:
711  OSystem *_system;
712  MacGuiImpl *_gui;
713 
714  MacDialogWindow(MacGuiImpl *gui, OSystem *system, Graphics::Surface *from, Common::Rect bounds, MacDialogWindowStyle windowStyle = kWindowStyleNormal, MacDialogMenuStyle menuStyle = kMenuStyleDisabled);
715  ~MacDialogWindow();
716 
717  Graphics::Surface *surface() { return &_surface; }
718  Graphics::Surface *innerSurface() { return &_innerSurface; }
719 
720  bool isVisible() const { return _visible; }
721 
722  void show();
723  bool runDialog(MacDialogEvent &dialogEvent);
724  void delayAndUpdate();
725  void updateCursor();
726 
727  uint getNumWidgets() const { return _widgets.size(); }
728 
729  MacWidget *getWidget(uint nr) const;
730  MacWidget *getWidget(MacWidgetType type, uint nr = 0) const;
731 
732  void setDefaultWidget(MacWidget *widget) { _defaultWidget = widget; }
733  MacWidget *getDefaultWidget() const { return _defaultWidget; }
734 
735  void setFocusedWidget(int x, int y);
736  void clearFocusedWidget();
737  MacWidget *getFocusedWidget() const { return _focusedWidget; }
738  Common::Point getFocusClick() const { return _focusClick; }
739  Common::Point getMousePos() const { return _mousePos; }
740 
741  int findWidget(int x, int y) const;
742 
743  MacGuiImpl::MacButton *addButton(Common::Rect bounds, Common::String text, bool enabled);
744  MacGuiImpl::MacCheckbox *addCheckbox(Common::Rect bounds, Common::String text, bool enabled);
745  MacGuiImpl::MacStaticText *addStaticText(Common::Rect bounds, Common::String text, bool enabled, Graphics::TextAlign alignment = Graphics::kTextAlignLeft);
746  MacGuiImpl::MacEditText *addEditText(Common::Rect bounds, Common::String text, bool enabled);
747  MacGuiImpl::MacImage *addIcon(int x, int y, int id, bool enabled);
748  MacGuiImpl::MacImage *addPicture(Common::Rect bounds, int id, bool enabled);
749  MacGuiImpl::
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);
752  MacGuiImpl::MacImageSlider *addImageSlider(Common::Rect bounds, MacImage *handle, bool enabled, int minX, int maxX, int minValue, int maxValue);
753  MacGuiImpl::MacListBox *addListBox(Common::Rect bounds, Common::StringArray texts, bool enabled, bool contentUntouchable = false);
754  MacGuiImpl::MacPopUpMenu *addPopUpMenu(Common::Rect bounds, Common::String text, int textWidth, Common::StringArray texts, bool enabled);
755 
756  void addControl(Common::Rect bounds, uint16 controlId);
757 
758  void addSubstitution(Common::String text) { _substitutions.push_back(text); }
759  void replaceSubstitution(int nr, Common::String text) { _substitutions[nr] = text; }
760 
761  bool hasSubstitution(uint n) const { return n < _substitutions.size(); }
762  Common::String &getSubstitution(uint n) { return _substitutions[n]; }
763 
764  void markRectAsDirty(Common::Rect r);
765  void update(bool fullRedraw = false);
766 
767  void drawPatternRoundRect(const Common::Rect &rect, int arc, uint32 color, bool filled, bool darkenOnly);
768 
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);
772  void drawSprite(const Graphics::Surface *sprite, int x, int y);
773  void drawSprite(const Graphics::Surface *sprite, int x, int y, Common::Rect clipRect);
774  void drawTexts(Common::Rect r, const TextLine *lines, bool inverse = false);
775  void drawTextBox(Common::Rect r, const TextLine *lines, bool inverse = false, int arc = 9);
776  };
777 
778  MacGuiImpl(ScummEngine *vm, const Common::Path &resourceFile);
779  virtual ~MacGuiImpl();
780 
781  Graphics::MacWindowManager *_windowManager = nullptr;
782 
783  virtual int getNumColors() const = 0;
784 
785  Graphics::Surface *surface() { return _surface; }
786  virtual uint32 getBlack() const;
787  virtual uint32 getWhite() const;
788 
789  uint32 _macWhite;
790  uint32 _macBlack;
791 
792  virtual const Common::String name() const = 0;
793 
794  Common::String readCString(uint8 *&data);
795  Common::String readPascalString(uint8 *&data);
796 
797  int toMacRoman(int unicode) const;
798 
799  void setPaletteDirty();
800  void updatePalette();
801 
802  virtual bool handleEvent(Common::Event event);
803 
804  static void menuCallback(int id, Common::String &name, void *data);
805  virtual bool initialize();
806  virtual void updateWindowManager();
807  virtual void updateMenus();
808 
809  const Graphics::Font *getFont(FontId fontId);
810  virtual const Graphics::Font *getFontByScummId(int32 id) = 0;
811 
812  bool loadIcon(int id, Graphics::Surface **icon, Graphics::Surface **mask);
813  Graphics::Surface *loadPict(int id);
814 
815  virtual bool isVerbGuiActive() const { return false; }
816  virtual void reset() {}
817  virtual void resetAfterLoad() = 0;
818  virtual void update(int delta) = 0;
819 
820  virtual bool runQuitDialog();
821  virtual bool runRestartDialog();
822 
823  virtual void setupCursor(int &width, int &height, int &hotspotX, int &hotspotY, int &animate) = 0;
824 
825  virtual Graphics::Surface *textArea() { return nullptr; }
826  virtual void clearTextArea() {}
827  virtual void initTextAreaForActor(Actor *a, byte color) {}
828  virtual void printCharToTextArea(int chr, int x, int y, int color) {}
829 
830  void setMacGuiColors(Graphics::Palette &palette);
831 
832  MacDialogWindow *createWindow(Common::Rect bounds, MacDialogWindowStyle style = kWindowStyleNormal, MacDialogMenuStyle menuStyle = kMenuStyleDisabled);
833  MacDialogWindow *createDialog(int dialogId);
834  MacDialogWindow *createDialog(int dialogId, Common::Rect bounds);
835  void drawBanner(char *message);
836  void undrawBanner();
837 
838  void drawBitmap(Graphics::Surface *s, Common::Rect r, const uint16 *bitmap, uint32 color) const;
839 };
840 
841 } // End of namespace Scumm
842 #endif
Definition: engine.h:105
void clear(bool shrinkArray=0)
Definition: hashmap.h:427
Definition: macgui_impl.h:52
Definition: macgui_impl.h:510
Definition: str.h:59
Definition: font.h:83
TextAlign
Definition: font.h:48
Definition: surface.h:67
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: rect.h:524
Definition: path.h:52
Definition: macgui_impl.h:411
Definition: queue.h:42
Definition: macwindowmanager.h:147
Definition: macgui_impl.h:454
Definition: scumm.h:508
Definition: macgui_impl.h:336
Definition: macgui_impl.h:587
void push_back(const T &element)
Definition: array.h:183
Definition: hashmap.h:85
Definition: events.h:210
Definition: macgui_impl.h:657
Definition: formatinfo.h:28
Definition: rect.h:144
Definition: macmenu.h:94
size_type size() const
Definition: array.h:318
Definition: macgui_impl.h:251
Definition: macgui_impl.h:625
Definition: actor.h:100
signed char * fill(signed char *first, signed char *last, Value val)
Definition: algorithm.h:168
Definition: macgui_impl.h:113
Definition: system.h:163
Simple class for handling a palette data.
Definition: palette.h:55
Definition: macgui_impl.h:469
Definition: actor.h:30
Definition: macgui_impl.h:199
Definition: macgui_impl.h:268
Definition: atari-screen.h:42