22 #ifndef GRAPHICS_MACTOOLBOX_MACTOOLBOX_H 23 #define GRAPHICS_MACTOOLBOX_MACTOOLBOX_H 25 #include "common/bitstream.h" 26 #include "common/hashmap.h" 27 #include "common/system.h" 29 #include "common/str.h" 30 #include "common/ustr.h" 32 #include "audio/mixer.h" 33 #include "graphics/cursor.h" 34 #include "graphics/framelimiter.h" 35 #include "graphics/macgui/macfontmanager.h" 36 #include "graphics/macgui/macwindow.h" 37 #include "graphics/macgui/macwindowmanager.h" 38 #include "graphics/mactoolbox/siphash/halfsip.h" 42 class PCSpeakerStream;
46 namespace MacToolbox {
88 bool _isBitMap =
false;
102 return Common::String::format(
"%02x%02x%02x%02x%02x%02x%02x%02x", data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]);
106 enum PictureOpType : uint16 {
124 kOpVersion2 = 0x0011,
125 kOpBkPixPat = 0x0012,
126 kOpPnPixPat = 0x0013,
127 kOpFillPixPat = 0x0014,
128 kOpPnLocHFrac = 0x0015,
133 kOpRGBFgCol = 0x001a,
134 kOpRGBBkCol = 0x001b,
135 kOpHiliteMode = 0x001c,
136 kOpHiliteColor = 0x001d,
137 kOpDefHilite = 0x001e,
140 kOpLineFrom = 0x0021,
141 kOpShortLine = 0x0022,
142 kOpShortLineFrom = 0x0023,
147 kOpLongText = 0x0028,
150 kOpDHDVText = 0x002b,
151 kOpFontName = 0x002c,
152 kOpLineJustify = 0x002d,
153 kOpGlyphState = 0x002e,
155 kOpFrameRect = 0x0030,
156 kOpPaintRect = 0x0031,
157 kOpEraseRect = 0x0032,
158 kOpInvertRect = 0x0033,
159 kOpFillRect = 0x0034,
163 kOpFrameSameRect = 0x0038,
164 kOpPaintSameRect = 0x0039,
165 kOpEraseSameRect = 0x003a,
166 kOpInvertSameRect = 0x003b,
167 kOpFillSameRect = 0x003c,
171 kOpFrameRRect = 0x0040,
172 kOpPaintRRect = 0x0041,
173 kOpEraseRRect = 0x0042,
174 kOpInvertRRect = 0x0043,
175 kOpFillRRect = 0x0044,
179 kOpFrameSameRRect = 0x0048,
180 kOpPaintSameRRect = 0x0049,
181 kOpEraseSameRRect = 0x004a,
182 kOpInvertSameRRect = 0x004b,
183 kOpFillSameRRect = 0x004c,
187 kOpFrameOval = 0x0050,
188 kOpPaintOval = 0x0051,
189 kOpEraseOval = 0x0052,
190 kOpInvertOval = 0x0053,
191 kOpFillOval = 0x0054,
195 kOpFrameSameOval = 0x0058,
196 kOpPaintSameOval = 0x0059,
197 kOpEraseSameOval = 0x005a,
198 kOpInvertSameOval = 0x005b,
199 kOpFillSameOval = 0x005c,
204 kOpFramePoly = 0x0070,
205 kOpPaintPoly = 0x0071,
206 kOpErasePoly = 0x0072,
207 kOpInvertPoly = 0x0073,
208 kOpFillPoly = 0x0074,
212 kOpFrameSamePoly = 0x0078,
213 kOpPaintSamePoly = 0x0079,
214 kOpEraseSamePoly = 0x007a,
215 kOpInvertSamePoly = 0x007b,
216 kOpFillSamePoly = 0x007c,
221 kOpBitsRect = 0x0090,
224 kOpPackBitsRect = 0x0098,
225 kOpPackBitsRgn = 0x0099,
227 kOpShortComment = 0x00a0,
228 kOpLongComment = 0x00a1,
232 kOpHeaderOp = 0x0c00,
233 kOpVersion1 = 0x1101,
248 uint32 _opsPerTick = 0;
250 void pushOp(PictureOpType op) {
255 void pushOpU16(PictureOpType op, uint16 val) {
263 void pushOpPoly(PictureOpType op,
const PolyHandle &poly);
264 void pushOpPat(PictureOpType op,
const Pattern &pat);
265 void pushOpRect(PictureOpType op,
const Common::Rect &rect);
266 void pushOpPoint(PictureOpType op,
const Common::Point &point);
273 typedef uint32 ResType;
284 void *target = h.
get();
286 Graphics::MacToolbox::halfsiphash((
const void *)&target,
sizeof(intptr_t),
"TBHANDLE", (byte *)&result,
sizeof(uint));
294 void *target = h.
get();
296 Graphics::MacToolbox::halfsiphash((
const void *)&target,
sizeof(intptr_t),
"TBHANDLE", (byte *)&result,
sizeof(uint));
304 namespace MacToolbox {
320 for (
int y = 0; y < 16; y++) {
321 for (
int x = 0; x < 16; x++) {
322 _surface[y*16+x] = (this->data[y] & (1 << (15 - x))) ? 1 : 0;
334 virtual const byte *
getMask()
const {
return _mask; }
341 byte _surface[16*16] = { 0 };
342 byte _mask[16*16] = { 0 };
343 byte _palette[6] = { 0xff, 0xff, 0xff, 0x00, 0x00, 0x00 };
344 uint16 _paletteCount = 2;
347 typedef uint32 OSType;
349 typedef uint32 ProcPtr;
352 enum OSErrCode : int16 {
385 enum EventCode : uint16 {
402 kScummVMQuitEvt = 24,
403 kScummVMReturnToLauncherEvt = 25,
406 enum ModifierMask : uint16 {
407 kModForegroundSwitch = 0x0001,
408 kModMouseButtonUp = 0x0080,
409 kModCommandKeyDown = 0x0100,
410 kModLShiftKeyDown = 0x0200,
411 kModCapsLockKeyDown = 0x0400,
412 kModLOptionKeyDown = 0x0800,
413 kModLControlKeyDown = 0x1000,
414 kModRShiftKeyDown = 0x2000,
415 kModROptionKeyDown = 0x4000,
416 kModRControlKeyDown = 0x8000,
419 enum SourceMode : uint16 {
430 enum PatternMode : uint16 {
441 enum WindowDefinition {
458 Pattern bkPat = { { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } };
459 Pattern fillPat = { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } };
462 PatternMode pnMode = kPatCopy;
463 Pattern pnPat = { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } };
467 SourceMode txMode = kSrcOr;
473 uint16 patStretch = 0;
487 EventCode what = kNullEvent;
492 uint16 modifiers = 0;
526 uint32 ioCmdAddr = 0;
527 uint32 ioCompletion = 0;
530 uint16 ioVRefNum = 0;
546 enum SynthMode : int16 {
590 uint32 Delay(uint32 numTicks);
598 void FlushEvents(uint32 eventMask, uint32 stopMask);
607 bool GetNextEvent(int32 eventMask,
EventRecord &theEvent);
635 void SetSoundVol(int16 level);
651 void StartSound(SynthPtr synthRec, uint32 numBytes, ProcPtr completionRtn);
667 void CloseResFile(int16 refNum);
674 uint16 CountResources(ResType theType);
686 void DetachResource(
Handle &h);
691 void DisposHandle(
Handle &h);
696 Size GetHandleSize(
Handle &h);
705 Handle GetIndResource(ResType theType, uint16 index);
724 Handle GetResource(ResType theType, uint16 theID);
730 int32 HomeResFile(
Handle &theResource);
736 Handle NewHandle(Size logicalSize);
754 void ReleaseResource(
Handle &handle);
762 int32 SizeResource(
Handle &theResource);
769 void UseResFile(int16 refNum);
787 void CheckItem(MenuHandle &theMenu, uint16 item,
bool checked);
796 uint16 CountMItems(MenuHandle &theMenu);
802 void DeleteMenu(uint16 menuID);
807 void DisableItem(MenuHandle &theMenu, uint16 item);
814 void DisposeMenu(MenuHandle &theMenu);
827 void EnableItem(MenuHandle &theMenu, uint16 item);
832 void GetItemMark(MenuHandle &theMenu, uint16 item, uint8 &markChar);
837 MenuHandle GetMHandle(uint16 menuID);
844 void HiliteMenu(uint16 menuID);
846 uint32 MenuKey(
char ch);
874 void SetItem(MenuHandle &theMenu, uint16 item,
const Common::U32String &itemString);
880 void SetItemMark(MenuHandle &theMenu, uint16 item, uint8 markChar);
922 void BackPat(
const Pattern &pat);
983 void EraseRoundRect(
const Common::Rect &r, uint16 ovalWidth, uint16 ovalHeight);
1010 void FillRoundRect(
const Common::Rect &r, uint16 ovalWidth, uint16 ovalHeight,
const Pattern &pat);
1017 void FrameArc(
const Common::Rect &r, int16 startAngle, int16 arcAngle);
1044 void FrameRoundRect(
const Common::Rect &r, uint16 ovalWidth, uint16 ovalHeight);
1049 void GetCPixel(int16 h, int16 v,
RGBColor &cPix);
1055 Handle GetIcon(uint16 iconID);
1063 void GetPort(GrafPtr &port);
1124 void InvertRoundRect(
const Common::Rect &r, uint16 ovalWidth, uint16 ovalHeight);
1136 void Line(int16 dh, int16 dv);
1141 void LineTo(int16 h, int16 v);
1154 void Move(int16 dh, int16 dv);
1159 void MovePortTo(int16 leftGlobal, int16 topGlobal);
1164 void MoveTo(int16 h, int16 v);
1183 void OpenPort(GrafPtr port);
1208 void PaintRoundRect(
const Common::Rect &r, uint16 ovalWidth, uint16 ovalHeight);
1213 void PenMode(PatternMode mode);
1224 void PenPat(
const Pattern &pat);
1230 void PenSize(uint16 width, uint16 height);
1241 void PortSize(uint16 width, uint16 height);
1252 void SetCPixel(int16 h, int16 v,
const RGBColor &cPix);
1262 void SetOrigin(int16 h, int16 v);
1266 void SetPort(GrafPtr port);
1273 void SetPortBits(
BitMap &bm);
1278 void SetRect(
Common::Rect &r, int16 left, int16 top, int16 right, int16 bottom);
1317 void TextFace(uint16 style);
1322 void TextFont(uint16 font);
1327 void TextMode(SourceMode mode);
1332 void TextSize(uint16 size);
1334 void _injectFOND(int16 resID,
const byte *data,
const size_t size,
const Common::String &name);
1336 void _loadFonts(int16 resID);
1338 void _setFileModalCallback(FileModalCallback callback) { _fileModalCallback = callback; }
1345 int16 _nextResId = 1;
1346 size_t _resIndexStart = 0;
1352 int _cursorLevel = 0;
1354 uint16 _modifiers = 0x80;
1361 GrafPtr _port =
nullptr;
1363 FileModalCallback _fileModalCallback;
1366 void _updateScreen();
1367 void _drawOval(
const Common::Rect &r,
const Pattern &pat, PatternMode mode,
bool frame, uint32 fgColor, uint32 bkColor);
1368 void _drawPoly(
const PolyHandle &p,
const Pattern &pat, PatternMode mode,
bool frame, uint32 fgColor, uint32 bkColor);
1369 void _drawRect(
const Common::Rect &r,
const Pattern &pat, PatternMode mode,
bool frame, uint32 fgColor, uint32 bkColor);
1370 void _drawRoundRect(
const Common::Rect &r,
const Pattern &pat, PatternMode mode,
bool frame, uint32 fgColor, uint32 bkColor, uint16 ovalWidth, uint16 ovalHeight);
Definition: framelimiter.h:40
static String format(MSVC_PRINTF const char *fmt,...) GCC_PRINTF(1
Definition: macwindow.h:205
Definition: macwindowmanager.h:149
PointerType get() const
Definition: ptr.h:229
Out copy(In first, In last, Out dst)
Definition: algorithm.h:52
Definition: macresman.h:77
void push_back(const T &element)
Definition: array.h:181
Definition: algorithm.h:29
Definition: formatinfo.h:28
char32_t u32char_type_t
Definition: ustr.h:41