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 "graphics/font.h" 39 class MacWindowManager;
60 bool _menuIsActive =
false;
61 bool _cursorWasVisible =
false;
66 byte _unicodeToMacRoman[96];
70 kDelayInterrupted = 1,
105 kAboutFontHeaderInside,
106 kAboutFontHeaderOutside,
110 kIndy3VerbFontRegular,
112 kIndy3VerbFontOutline,
134 enum MacDialogWindowStyle {
139 MacGuiImpl::DelayStatus delay(uint32 ms = 0);
141 virtual bool getFontParams(FontId fontId,
int &
id,
int &size,
int &slant)
const;
147 virtual void runAboutDialog() = 0;
148 virtual bool runOpenDialog(
int &saveSlotToHandle) = 0;
149 virtual bool runSaveDialog(
int &saveSlotToHandle,
Common::String &name) = 0;
150 virtual bool runOptionsDialog() = 0;
151 void prepareSaveLoad(
Common::StringArray &savegameNames,
bool *availSlots,
int *slotIds,
int size);
159 bool _redraw =
false;
160 bool _enabled =
false;
161 bool _visible =
true;
168 bool getRedraw()
const {
return _redraw; }
169 bool isEnabled()
const {
return _enabled; }
170 bool isVisible()
const {
return _visible; }
178 bool _fullRedraw =
false;
184 void drawBitmap(
Common::Rect r,
const uint16 *bitmap, Color color)
const;
190 void setId(
int id) { _id = id; }
191 int getId()
const {
return _id; }
195 void setVisible(
bool visible) { _visible = visible; }
197 virtual void getFocus() { setRedraw(); }
198 virtual void loseFocus() { setRedraw(); }
200 virtual void setRedraw(
bool fullRedraw =
false);
202 void setEnabled(
bool enabled);
204 virtual void setValue(
int value);
205 int getValue()
const {
return _value; }
209 virtual bool useBeamCursor() {
return false; }
210 virtual bool findWidget(
int x,
int y)
const;
211 virtual bool shouldDeferAction() {
return false; }
213 virtual void draw(
bool drawFocused =
false) = 0;
216 virtual bool handleDoubleClick(
Common::Event &event) {
return false; }
217 virtual bool handleMouseUp(
Common::Event &event) {
return false; }
219 virtual void handleMouseHeld() {}
220 virtual void handleWheelUp() {}
221 virtual void handleWheelDown() {}
222 virtual bool handleKeyDown(
Common::Event &event) {
return false; }
232 void hLine(
int x0,
int y0,
int x1,
bool enabled);
233 void vLine(
int x0,
int y0,
int y1,
bool enabled);
234 void drawCorners(
Common::Rect r, CornerLine *corner,
bool enabled);
239 void draw(
bool drawFocused =
false);
251 bool findWidget(
int x,
int y)
const;
252 void draw(
bool drawFocused =
false);
264 bool _wordWrap =
false;
272 void setWordWrap(
bool wordWrap) { _wordWrap = wordWrap; }
281 void setColor(Color fg, Color bg) {
282 if (fg != _fg || bg != _bg) {
289 void draw(
bool drawFocused =
false);
296 uint _maxLength = 31;
303 uint32 _nextCaretBlink = 0;
304 bool _caretVisible =
true;
309 int getTextPosFromMouse(
int x,
int y);
311 void updateSelection(
int x,
int y);
312 void deleteSelection();
317 void getFocus()
override {}
318 void loseFocus()
override {}
322 bool useBeamCursor()
override {
return true; }
323 bool findWidget(
int x,
int y)
const override;
324 bool shouldDeferAction()
override {
return true; }
326 void draw(
bool drawFocused =
false)
override;
331 void handleMouseHeld()
override;
345 void draw(
bool drawFocused =
false);
355 int _grabOffset = -1;
357 int calculateValueFromPos()
const;
358 int calculatePosFromValue()
const;
362 :
MacWidget(window, bounds,
"SliderBase", enabled),
363 _minValue(minValue), _maxValue(maxValue),
364 _minPos(minPos), _maxPos(maxPos) {}
369 void setValue(
int value);
380 bool _upArrowPressed =
false;
381 bool _downArrowPressed =
false;
391 void drawUpArrow(
bool markAsDirty);
392 void drawDownArrow(
bool markAsDirty);
393 void drawArrow(
Common::Rect r,
const uint16 *bitmap,
bool markAsDirty);
395 void eraseDragHandle();
401 bool isScrollable()
const {
return (_maxValue - _minValue) > 0; }
402 int getPageSize()
const {
return _pageSize; }
404 bool findWidget(
int x,
int y)
const;
405 void draw(
bool drawFocued =
false);
406 void redrawHandle(
int oldValue,
int newValue);
411 void handleMouseHeld();
412 void handleWheelUp();
413 void handleWheelDown();
428 :
MacSliderBase(window, background->getBounds(), minValue, maxValue, minX + leftMargin, maxX - rightMargin, enabled),
429 _background(background), _handle(handle), _minX(minX),
432 bool findWidget(
int x,
int y)
const;
433 void draw(
bool drawFocused =
false);
438 void handleWheelUp();
439 void handleWheelDown();
447 bool _sliderFocused =
false;
450 void handleWheel(
int distance);
459 void setValue(
int value) {
460 if (value != _value) {
470 bool findWidget(
int x,
int y)
const;
471 void setRedraw(
bool fullRedraw =
false);
472 void draw(
bool drawFocused =
false);
478 void handleMouseHeld();
479 void handleWheelUp();
480 void handleWheelDown();
486 bool _shakeWasEnabled;
491 bool _visible =
false;
493 uint32 _lastClickTime = 0;
498 bool _cursorWasVisible =
false;
499 bool _beamCursorVisible =
false;
500 const int _beamCursorHotspotX = 3;
501 const int _beamCursorHotspotY = 4;
503 void drawBeamCursor();
504 void undrawBeamCursor();
538 bool isVisible()
const {
return _visible; }
544 MacWidget *getWidget(
int nr)
const {
return _widgets[nr]; }
545 void setDefaultWidget(
int nr) { _defaultWidget = _widgets[nr]; }
546 MacWidget *getDefaultWidget()
const {
return _defaultWidget; }
548 void setFocusedWidget(
int x,
int y);
549 void clearFocusedWidget();
550 MacWidget *getFocusedWidget()
const {
return _focusedWidget; }
554 void setWidgetEnabled(
int nr,
bool enabled) { _widgets[nr]->setEnabled(enabled); }
555 bool isWidgetEnabled(
int nr)
const {
return _widgets[nr]->isEnabled(); }
556 void setWidgetVisible(
int nr,
bool visible) { _widgets[nr]->setVisible(visible); }
557 int getWidgetValue(
int nr)
const {
return _widgets[nr]->getValue(); }
558 void setWidgetValue(
int nr,
int value) { _widgets[nr]->setValue(value); }
559 int findWidget(
int x,
int y)
const;
560 void redrawWidget(
int nr) { _widgets[nr]->setRedraw(
true); }
567 MacGuiImpl::MacSlider *addSlider(
int x,
int y,
int h,
int minValue,
int maxValue,
int pageSize,
bool enabled);
568 MacGuiImpl::MacPictureSlider *addPictureSlider(
int backgroundId,
int handleId,
bool enabled,
int minX,
int maxX,
int minValue,
int maxValue,
int leftMargin = 0,
int rightMargin = 0);
572 void replaceSubstitution(
int nr,
Common::String text) { _substitutions[nr] = text; }
574 bool hasSubstitution(uint n)
const {
return n < _substitutions.
size(); }
575 Common::String &getSubstitution(uint n) {
return _substitutions[n]; }
578 void update(
bool fullRedraw =
false);
580 static void plotPixel(
int x,
int y,
int color,
void *data);
581 static void plotPattern(
int x,
int y,
int pattern,
void *data);
582 static void plotPatternDarkenOnly(
int x,
int y,
int pattern,
void *data);
584 void drawDottedHLine(
int x0,
int y,
int x1);
596 bool _forceMenuClosed =
false;
602 int toMacRoman(
int unicode)
const;
604 void setPalette(
const byte *palette, uint size);
607 static void menuCallback(
int id,
Common::String &name,
void *data);
608 virtual void initialize();
609 void updateWindowManager();
616 virtual bool isVerbGuiActive()
const {
return false; }
617 virtual void reset() {}
618 virtual void resetAfterLoad() = 0;
619 virtual void update(
int delta) = 0;
621 bool runQuitDialog();
622 bool runRestartDialog();
624 virtual void setupCursor(
int &width,
int &height,
int &hotspotX,
int &hotspotY,
int &animate) = 0;
627 virtual void clearTextArea() {}
628 virtual void initTextAreaForActor(
Actor *a, byte color) {}
629 virtual void printCharToTextArea(
int chr,
int x,
int y,
int color) {}
633 void drawBanner(
char *message);
Definition: macgui_impl.h:47
Definition: macgui_impl.h:372
TextAlign
Definition: font.h:48
Definition: macgui_impl.h:260
Definition: macgui_impl.h:244
Align the text to the left.
Definition: font.h:51
Definition: macgui_impl.h:292
Definition: macwindowmanager.h:148
Definition: macgui_impl.h:416
Definition: macgui_impl.h:442
void push_back(const T &element)
Definition: array.h:142
Definition: macgui_impl.h:484
Definition: formatinfo.h:28
size_type size() const
Definition: array.h:275
Definition: macgui_impl.h:156
Definition: macgui_impl.h:335
signed char * fill(signed char *first, signed char *last, Value val)
Definition: algorithm.h:111
Definition: macgui_impl.h:348
Definition: macgui_impl.h:126