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
38class OSystem;
39
40namespace Graphics {
41struct Surface;
42class Palette;
43class MacWindowManager;
44class MacMenu;
45}
46
47namespace Scumm {
48
49class ScummEngine;
50class Actor;
51
53public:
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
136protected:
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
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;
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
250public:
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 virtual bool keepFocus(int x, int y) { return false; }
303
304 virtual void setRedraw(bool fullRedraw = false);
305
306 void setEnabled(bool enabled);
307
308 virtual void setValue(int value);
309 int getValue() const { return _value; }
310
311 void rememberValue() {
312 _oldValue = _value;
313 }
314
315 bool valueHasChanged() {
316 return _oldValue != _value;
317 }
318
319 Common::String getText() const;
320
321 virtual bool useBeamCursor() { return false; }
322 virtual bool findWidget(int x, int y) const;
323 virtual bool reactsToKeyDown() { return false; }
324
325 virtual void draw(bool drawFocused = false) = 0;
326
327 virtual void handleMouseDown(Common::Event &event) {}
328 virtual bool handleDoubleClick(Common::Event &event) { return false; }
329 virtual bool handleMouseUp(Common::Event &event) { return false; }
330 virtual void handleMouseMove(Common::Event &event) {}
331 virtual void handleMouseHeld() {}
332 virtual void handleWheelUp() {}
333 virtual void handleWheelDown() {}
334 virtual bool handleKeyDown(Common::Event &event) { return false; }
335 };
336
337 class MacButton : public MacWidget {
338 private:
339 struct CornerLine {
340 int start;
341 int length;
342 };
343
344 void hLine(int x0, int y0, int x1, bool enabled);
345 void vLine(int x0, int y0, int y1, bool enabled);
346 void drawCorners(Common::Rect r, CornerLine *corner, bool enabled);
347
348 public:
349 MacButton(MacGuiImpl::MacDialogWindow *window, Common::Rect bounds, Common::String text, bool enabled) : MacWidget(window, bounds, text, enabled) {}
350
351 void draw(bool drawFocused = false) override;
352
353 bool handleMouseUp(Common::Event &event) override { return true; }
354 };
355
356 class MacCheckbox : public MacWidget {
357 private:
358 Common::Rect _hitBounds;
359
360 public:
361 MacCheckbox(MacGuiImpl::MacDialogWindow *window, Common::Rect bounds, Common::String text, bool enabled);
362
363 bool findWidget(int x, int y) const override;
364 void draw(bool drawFocused = false) override;
365 bool handleMouseUp(Common::Event &event) override;
366 };
367
368 // The dialogs add texts as disabled, but we don't want it to be drawn
369 // as disabled so we enable it and make it "disabled" by giving it a
370 // custom findWidget().
371
372 class MacStaticText : public MacWidget {
373 private:
374 uint32 _fg;
375 uint32 _bg;
377 bool _wordWrap = true;
378
379 public:
382 Common::Rect bounds, Common::String text,
383 bool enabled, Graphics::TextAlign alignment = Graphics::kTextAlignLeft) : MacWidget(window, bounds, text, true) {
384 _alignment = alignment;
385 _fg = _black;
386 _bg = _white;
387 }
388
389 void getFocus() override {}
390 void loseFocus() override {}
391
392 void setWordWrap(bool wordWrap) { _wordWrap = wordWrap; }
393
394 void setText(Common::String text) {
395 if (text != _text) {
396 _text = text;
397 setRedraw();
398 }
399 }
400
401 void setColor(uint32 fg, uint32 bg) {
402 if (fg != _fg || bg != _bg) {
403 _fg = fg;
404 _bg = bg;
405 setRedraw();
406 }
407 }
408
409 void draw(bool drawFocused = false) override;
410 };
411
412 class MacEditText : public MacWidget {
413 private:
414 // Max length of a SCUMM saved game name. We could make this
415 // configurable later, if needed.
416 uint _maxLength = 31;
417
418 int _textPos = 1;
419 int _selectLen = 0;
420 int _caretPos = 0;
421 int _caretX = -1;
422
423 uint32 _nextCaretBlink = 0;
424 bool _caretVisible = true;
425
426 const Graphics::Font *_font;
427 Graphics::Surface _textSurface;
428
429 int getTextPosFromMouse(int x, int y);
430
431 void updateSelection(int x, int y);
432 void deleteSelection();
433
434 public:
435 MacEditText(MacGuiImpl::MacDialogWindow *window, Common::Rect bounds, Common::String text, bool enabled);
436
437 void getFocus() override {}
438 void loseFocus() override {}
439
440 void selectAll();
441
442 bool useBeamCursor() override { return true; }
443 bool findWidget(int x, int y) const override;
444 bool reactsToKeyDown() override { return true; }
445
446 void draw(bool drawFocused = false) override;
447
448 void handleMouseDown(Common::Event &event) override;
449 bool handleDoubleClick(Common::Event &event) override;
450 bool handleKeyDown(Common::Event &event) override;
451 void handleMouseHeld() override;
452 void handleMouseMove(Common::Event &event) override;
453 };
454
455 class MacImage : public MacWidget {
456 private:
457 Graphics::Surface *_image = nullptr;
458 Graphics::Surface *_mask = nullptr;
459
460 public:
461 MacImage(MacGuiImpl::MacDialogWindow *window, Common::Rect bounds, Graphics::Surface *surface, Graphics::Surface *mask, bool enabled);
462 ~MacImage();
463
464 Graphics::Surface *getImage() const { return _image; }
465 Graphics::Surface *getMask() const { return _mask; }
466
467 void draw(bool drawFocused = false) override;
468 };
469
470 class MacSliderBase : public MacWidget {
471 protected:
472 int _minValue;
473 int _maxValue;
474 int _minPos;
475 int _maxPos;
476 int _handlePos = -1;
477 int _grabOffset = -1;
478
479 Common::HashMap<int, int> _posToValue;
480 Common::HashMap<int, int> _valueToPos;
481
482 int calculateValueFromPos(int pos) const;
483 int calculatePosFromValue(int value) const;
484 int calculateValueFromPos() const;
485 int calculatePosFromValue() const;
486
487 public:
488 MacSliderBase(MacGuiImpl::MacDialogWindow *window, Common::Rect bounds, int minValue, int maxValue, int minPos, int maxPos, bool enabled)
489 : MacWidget(window, bounds, "SliderBase", enabled),
490 _minValue(minValue), _maxValue(maxValue),
491 _minPos(minPos), _maxPos(maxPos) {}
492
493 virtual ~MacSliderBase() {
494 _posToValue.clear();
495 _valueToPos.clear();
496 }
497
498 void getFocus() override {}
499 void loseFocus() override {}
500
501 int getMinValue() const { return _minValue; }
502 int getMaxValue() const { return _maxValue; }
503 void setValue(int value) override;
504
505 void addStop(int pos, int value) {
506 _posToValue[pos] = value;
507 _valueToPos[value] = pos;
508 }
509 };
510
511 class MacSlider : public MacSliderBase {
512 private:
513 Common::Point _clickPos;
514 uint32 _nextRepeat = 0;
515
516 int _pageSize = 0;
517 int _paging = 0;
518
519 bool _upArrowPressed = false;
520 bool _downArrowPressed = false;
521
522 Common::Rect _boundsButtonUp;
523 Common::Rect _boundsButtonDown;
524 Common::Rect _boundsBody;
525
526 Common::Rect getHandleRect(int value);
527
528 void fill(Common::Rect r, bool inverted = false);
529
530 void drawUpArrow(bool markAsDirty);
531 void drawDownArrow(bool markAsDirty);
532 void drawArrow(Common::Rect r, const uint16 *bitmap, bool markAsDirty);
533
534 void eraseDragHandle();
535 void drawHandle(Common::Rect r);
536
537 public:
538 MacSlider(MacGuiImpl::MacDialogWindow *window, Common::Rect bounds, int minValue, int maxValue, int pageSize, bool enabled);
539
540 bool isScrollable() const { return (_maxValue - _minValue) > 0; }
541 int getPageSize() const { return _pageSize; }
542
543 bool findWidget(int x, int y) const override;
544 void draw(bool drawFocued = false) override;
545 void redrawHandle(int oldValue, int newValue);
546
547 void handleMouseDown(Common::Event &event) override;
548 bool handleMouseUp(Common::Event &event) override;
549 void handleMouseMove(Common::Event &event) override;
550 void handleMouseHeld() override;
551 void handleWheelUp() override;
552 void handleWheelDown() override;
553 };
554
556 private:
557 Graphics::Surface *_background;
558 MacImage *_handle;
559 int _minX;
560 int _maxX;
561 bool _freeBackground = false;
562 bool _snapWhileDragging = false;
563
564 void eraseHandle();
565 void drawHandle();
566
567 public:
568 MacImageSlider(MacGuiImpl::MacDialogWindow *window, MacImage *background, MacImage *handle, bool enabled, int minX, int maxX, int minValue, int maxValue, int leftMargin, int rightMargin)
569 : MacSliderBase(window, background->getBounds(), minValue, maxValue, minX + leftMargin, maxX - rightMargin, enabled),
570 _background(background->getImage()), _handle(handle), _minX(minX), _maxX(maxX) {}
571 MacImageSlider(MacGuiImpl::MacDialogWindow *window, Common::Rect bounds, MacImage *handle, bool enabled, int minX, int maxX, int minValue, int maxValue);
573
574 void setValue(int value) override;
575
576 bool findWidget(int x, int y) const override;
577 void draw(bool drawFocused = false) override;
578
579 void setSnapWhileDragging(bool snap) { _snapWhileDragging = snap; }
580
581 void handleMouseDown(Common::Event &event) override;
582 bool handleMouseUp(Common::Event &event) override;
583 void handleMouseMove(Common::Event &event) override;
584 void handleWheelUp() override;
585 void handleWheelDown() override;
586 };
587
588 class MacListBox : public MacWidget {
589 private:
590 Common::StringArray _texts;
592 MacSlider *_slider;
593 bool _sliderFocused = false;
594
595 void updateTexts();
596 void handleWheel(int distance);
597
598 public:
599 MacListBox(MacGuiImpl::MacDialogWindow *window, Common::Rect bounds, Common::StringArray texts, bool enabled, bool contentUntouchable = true);
600 ~MacListBox();
601
602 void getFocus() override {}
603 void loseFocus() override {}
604
605 void setValue(int value) override {
606 if (value != _value) {
607 _value = value;
608 updateTexts();
609 }
610 }
611
612 bool findWidget(int x, int y) const override;
613 void setRedraw(bool fullRedraw = false) override;
614 void draw(bool drawFocused = false) override;
615
616 void handleMouseDown(Common::Event &event) override;
617 bool handleDoubleClick(Common::Event &event) override;
618 bool handleMouseUp(Common::Event &event) override;
619 void handleMouseMove(Common::Event &event) override;
620 void handleMouseHeld() override;
621 void handleWheelUp() override;
622 void handleWheelDown() override;
623 bool handleKeyDown(Common::Event &event) override;
624 };
625
626 class MacPopUpMenu : public MacWidget {
627 private:
628 Common::StringArray _texts;
629 int _textWidth;
630 bool _menuVisible = false;
631 int _selected;
632 Graphics::Surface _popUpBackground;
633 Common::Rect _popUpBounds;
634 bool _floating;
635 bool _enhUIUX;
636
637 void close();
638
639 public:
640 MacPopUpMenu(MacGuiImpl::MacDialogWindow *window, Common::Rect bounds, Common::String text, int textWidth, Common::StringArray texts, bool enabled);
642
643 bool findWidget(int x, int y) const override;
644 void draw(bool drawFocused = false) override;
645
646 void handleMouseDown(Common::Event &event) override;
647 bool handleMouseUp(Common::Event &event) override;
648 void handleMouseMove(Common::Event &event) override;
649
650 void loseFocus() override;
651 bool keepFocus(int x, int y) override;
652 };
653
654 enum MacDialogEventType {
655 kDialogClick,
656 kDialogValueChange,
657 kDialogKeyDown
658 };
659
661 MacWidget *widget;
662 MacDialogEventType type;
663 };
664
666 private:
668 uint32 _black;
669 uint32 _white;
670
671 bool _shakeWasEnabled;
672
673 Common::Rect _bounds;
674 int _margin;
675
676 bool _visible = false;
677
678 uint32 _lastClickTime = 0;
679 Common::Point _lastClickPos;
680
681 Graphics::Surface *_beamCursor = nullptr;
682 Common::Point _beamCursorPos;
683 bool _cursorWasVisible = false;
684 bool _beamCursorVisible = false;
685 const int _beamCursorHotspotX = 3;
686 const int _beamCursorHotspotY = 4;
687
688 void drawBeamCursor();
689 void undrawBeamCursor();
690
691 PauseToken _pauseToken;
692
693 Graphics::Surface *_from = nullptr;
694 Graphics::Surface *_backup = nullptr;
695 Graphics::Surface _surface;
696 Graphics::Surface _innerSurface;
697
699
700 MacWidget *_defaultWidget = nullptr;
701
702 MacWidget *_focusedWidget = nullptr;
703 Common::Point _oldMousePos;
704 Common::Point _mousePos;
705 Common::Point _realMousePos;
706
707 Common::StringArray _substitutions;
708 Common::Array<Common::Rect> _dirtyRects;
709 bool _dirtyPalette = false;
710
711 void queueEvent(MacGuiImpl::MacWidget *widget, MacGuiImpl::MacDialogEventType type);
712
713 void copyToScreen(Graphics::Surface *s = nullptr) const;
714
715 void addWidget(MacWidget *widget, MacWidgetType type);
716
717 public:
718 OSystem *_system;
719 MacGuiImpl *_gui;
720
721 MacDialogWindow(MacGuiImpl *gui, OSystem *system, Graphics::Surface *from, Common::Rect bounds, MacDialogWindowStyle windowStyle = kWindowStyleNormal, MacDialogMenuStyle menuStyle = kMenuStyleDisabled);
723
724 Graphics::Surface *surface() { return &_surface; }
725 Graphics::Surface *innerSurface() { return &_innerSurface; }
726
727 bool isVisible() const { return _visible; }
728
729 void show();
730 bool runDialog(MacDialogEvent &dialogEvent);
731 void delayAndUpdate();
732 void updateCursor();
733
734 uint getNumWidgets() const { return _widgets.size(); }
735
736 MacWidget *getWidget(uint nr) const;
737 MacWidget *getWidget(MacWidgetType type, uint nr = 0) const;
738
739 void setDefaultWidget(MacWidget *widget) { _defaultWidget = widget; }
740 MacWidget *getDefaultWidget() const { return _defaultWidget; }
741
742 void setFocusedWidget(int x, int y);
743 void clearFocusedWidget();
744 MacWidget *getFocusedWidget() const { return _focusedWidget; }
745 Common::Point getMousePos() const { return _mousePos; }
746
747 int findWidget(int x, int y) const;
748
749 MacGuiImpl::MacButton *addButton(Common::Rect bounds, Common::String text, bool enabled);
750 MacGuiImpl::MacCheckbox *addCheckbox(Common::Rect bounds, Common::String text, bool enabled);
751 MacGuiImpl::MacStaticText *addStaticText(Common::Rect bounds, Common::String text, bool enabled, Graphics::TextAlign alignment = Graphics::kTextAlignLeft);
752 MacGuiImpl::MacEditText *addEditText(Common::Rect bounds, Common::String text, bool enabled);
753 MacGuiImpl::MacImage *addIcon(int x, int y, int id, bool enabled);
754 MacGuiImpl::MacImage *addPicture(Common::Rect bounds, int id, bool enabled);
755 MacGuiImpl::MacSlider *addSlider(int x, int y, int h, int minValue, int maxValue, int pageSize, bool enabled);
756 MacGuiImpl::MacImageSlider *addImageSlider(int backgroundId, int handleId, bool enabled, int minX, int maxX, int minValue, int maxValue, int leftMargin = 0, int rightMargin = 0);
757 MacGuiImpl::MacImageSlider *addImageSlider(Common::Rect bounds, MacImage *handle, bool enabled, int minX, int maxX, int minValue, int maxValue);
758 MacGuiImpl::MacListBox *addListBox(Common::Rect bounds, Common::StringArray texts, bool enabled, bool contentUntouchable = false);
759 MacGuiImpl::MacPopUpMenu *addPopUpMenu(Common::Rect bounds, Common::String text, int textWidth, Common::StringArray texts, bool enabled);
760
761 void addControl(Common::Rect bounds, uint16 controlId);
762
763 void addSubstitution(Common::String text) { _substitutions.push_back(text); }
764 void replaceSubstitution(int nr, Common::String text) { _substitutions[nr] = text; }
765
766 bool hasSubstitution(uint n) const { return n < _substitutions.size(); }
767 Common::String &getSubstitution(uint n) { return _substitutions[n]; }
768
769 void markRectAsDirty(Common::Rect r);
770 void update(bool fullRedraw = false);
771
772 void drawPatternRoundRect(const Common::Rect &rect, int arc, uint32 color, bool filled, bool darkenOnly);
773
774 void drawDottedHLine(int x0, int y, int x1);
775 void fillPattern(Common::Rect r, uint16 pattern, bool fillBlack = true, bool fillWhite = true);
776 void drawSprite(const MacImage *image, int x, int y);
777 void drawSprite(const Graphics::Surface *sprite, int x, int y);
778 void drawSprite(const Graphics::Surface *sprite, int x, int y, Common::Rect clipRect);
779 void drawTexts(Common::Rect r, const TextLine *lines, bool inverse = false);
780 void drawTextBox(Common::Rect r, const TextLine *lines, bool inverse = false, int arc = 9);
781 };
782
783 MacGuiImpl(ScummEngine *vm, const Common::Path &resourceFile);
784 virtual ~MacGuiImpl();
785
786 Graphics::MacWindowManager *_windowManager = nullptr;
787
788 virtual int getNumColors() const = 0;
789
790 Graphics::Surface *surface() { return _surface; }
791 virtual uint32 getBlack() const;
792 virtual uint32 getWhite() const;
793
794 uint32 _macWhite;
795 uint32 _macBlack;
796
797 virtual const Common::String name() const = 0;
798
799 Common::String readCString(uint8 *&data);
800 Common::String readPascalString(uint8 *&data);
801
802 int toMacRoman(int unicode) const;
803
804 void setPaletteDirty();
805 void updatePalette();
806
807 virtual bool handleEvent(Common::Event event);
808
809 static void menuCallback(int id, Common::String &name, void *data);
810 virtual bool initialize();
811 virtual void updateWindowManager();
812 virtual void updateMenus();
813
814 const Graphics::Font *getFont(FontId fontId);
815 virtual const Graphics::Font *getFontByScummId(int32 id) = 0;
816
817 bool loadIcon(int id, Graphics::Surface **icon, Graphics::Surface **mask);
818 Graphics::Surface *loadPict(int id);
819
820 virtual bool isVerbGuiActive() const { return false; }
821 virtual void reset() {}
822 virtual void resetAfterLoad() = 0;
823 virtual void update(int delta) = 0;
824
825 void queryQuit(bool returnToLauncher);
826
827 virtual bool runQuitDialog();
828 virtual bool runRestartDialog();
829
830 virtual void setupCursor(int &width, int &height, int &hotspotX, int &hotspotY, int &animate) = 0;
831
832 virtual Graphics::Surface *textArea() { return nullptr; }
833 virtual void clearTextArea() {}
834 virtual void initTextAreaForActor(Actor *a, byte color) {}
835 virtual void printCharToTextArea(int chr, int x, int y, int color) {}
836
837 void setMacGuiColors(Graphics::Palette &palette);
838
839 MacDialogWindow *createWindow(Common::Rect bounds, MacDialogWindowStyle style = kWindowStyleNormal, MacDialogMenuStyle menuStyle = kMenuStyleDisabled);
840 MacDialogWindow *createDialog(int dialogId);
841 MacDialogWindow *createDialog(int dialogId, Common::Rect bounds);
842 void drawBanner(char *message);
843 void undrawBanner();
844
845 void drawBitmap(Graphics::Surface *s, Common::Rect r, const uint16 *bitmap, uint32 color) const;
846};
847
848} // End of namespace Scumm
849#endif
size_type size() const
Definition: array.h:316
void push_back(const T &element)
Definition: array.h:181
Definition: path.h:52
Definition: queue.h:42
Definition: str.h:59
Definition: font.h:83
Definition: macmenu.h:95
Definition: macwindowmanager.h:149
Simple class for handling a palette data.
Definition: palette.h:61
Definition: system.h:166
Definition: atari-screen.h:42
Definition: engine.h:111
Definition: macgui_impl.h:337
Definition: macgui_impl.h:356
Definition: macgui_impl.h:665
Definition: macgui_impl.h:412
Definition: macgui_impl.h:251
Definition: macgui_impl.h:455
Definition: macgui_impl.h:555
Definition: macgui_impl.h:588
Definition: macgui_impl.h:626
Definition: macgui_impl.h:470
Definition: macgui_impl.h:511
Definition: macgui_impl.h:372
Definition: macgui_impl.h:268
Definition: macgui_impl.h:52
Definition: scumm.h:536
void clear(bool shrinkArray=0)
Definition: hashmap.h:431
TextAlign
Definition: font.h:48
@ kTextAlignLeft
Align the text to the left.
Definition: font.h:51
Definition: formatinfo.h:28
Definition: actor.h:30
Definition: events.h:218
Definition: rect.h:144
Definition: rect.h:536
Definition: surface.h:67
Definition: macgui_impl.h:660
Definition: macgui_impl.h:113
Definition: macgui_impl.h:199