2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2011-02-25 01:05:47 +03:00
|
|
|
// $Id$
|
2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2017-01-03 23:59:59 +03:00
|
|
|
// Copyright (C) 2001-2017 The Bochs Project
|
2001-04-10 05:04:59 +04:00
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
2009-02-08 12:05:52 +03:00
|
|
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2008-02-16 01:05:43 +03:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
// macintosh.cc -- bochs GUI file for the Macintosh
|
|
|
|
// written by David Batterham <drbatter@progsoc.uts.edu.au>
|
|
|
|
// with contributions from Tim Senecal
|
|
|
|
|
2002-10-25 01:07:56 +04:00
|
|
|
// Define BX_PLUGGABLE in files that can be compiled into plugins. For
|
2008-02-06 01:57:43 +03:00
|
|
|
// platforms that require a special tag on exported symbols, BX_PLUGGABLE
|
2002-10-25 01:07:56 +04:00
|
|
|
// is used to know when we are exporting symbols and when we are importing.
|
|
|
|
#define BX_PLUGGABLE
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
// BOCHS INCLUDES
|
2004-02-07 01:28:00 +03:00
|
|
|
#include <MacTypes.h>
|
2010-02-26 17:18:19 +03:00
|
|
|
|
|
|
|
#include "param_names.h"
|
2001-04-10 05:04:59 +04:00
|
|
|
#include "bochs.h"
|
2004-06-19 19:20:15 +04:00
|
|
|
#include "iodev.h"
|
2002-11-19 08:47:45 +03:00
|
|
|
|
|
|
|
// decide whether to enable this file or not
|
|
|
|
#if BX_WITH_MACOS
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
#include "icon_bochs.h"
|
|
|
|
#include "font/vga.bitmap.h"
|
|
|
|
|
|
|
|
// MAC OS INCLUDES
|
2004-02-08 21:11:45 +03:00
|
|
|
#undef ACCESSOR_CALLS_ARE_FUNCTIONS
|
|
|
|
#define ACCESSOR_CALLS_ARE_FUNCTIONS 1
|
2001-04-10 05:04:59 +04:00
|
|
|
#include <Quickdraw.h>
|
|
|
|
#include <QuickdrawText.h>
|
|
|
|
#include <QDOffscreen.h>
|
|
|
|
#include <Icons.h>
|
2004-02-08 21:11:45 +03:00
|
|
|
#include <ImageCompression.h>
|
2001-04-10 05:04:59 +04:00
|
|
|
#include <Palettes.h>
|
|
|
|
#include <Windows.h>
|
|
|
|
#include <Memory.h>
|
|
|
|
#include <Events.h>
|
|
|
|
#include <TextUtils.h>
|
2002-12-12 18:29:45 +03:00
|
|
|
#include <ToolUtils.h>
|
2001-04-10 05:04:59 +04:00
|
|
|
#include <Dialogs.h>
|
|
|
|
#include <LowMem.h>
|
|
|
|
#include <Disks.h>
|
|
|
|
#include <CursorDevices.h>
|
|
|
|
#include <Menus.h>
|
|
|
|
#include <Sound.h>
|
|
|
|
#include <SIOUX.h>
|
2002-12-12 18:29:45 +03:00
|
|
|
#include <Devices.h>
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
// CONSTANTS
|
|
|
|
|
2004-02-07 01:28:00 +03:00
|
|
|
#define rMBarID 128
|
|
|
|
#define mApple 128
|
|
|
|
#define iAbout 1
|
|
|
|
#define mFile 129
|
|
|
|
#define iQuit 1
|
|
|
|
#define mEdit 130
|
|
|
|
#define mBochs 131
|
|
|
|
#define iFloppy 1
|
|
|
|
#define iCursor 3
|
|
|
|
#define iTool 4
|
|
|
|
#define iMenuBar 5
|
|
|
|
#define iFullScreen 6
|
|
|
|
#define iConsole 7
|
|
|
|
#define iSnapshot 9
|
|
|
|
#define iReset 10
|
|
|
|
|
|
|
|
#define SLEEP_TIME 0 // Number of ticks to surrender the processor during a WaitNextEvent()
|
2001-04-10 05:04:59 +04:00
|
|
|
// Change this to 15 or higher if you don't want Bochs to hog the processor!
|
|
|
|
|
2004-02-07 01:28:00 +03:00
|
|
|
#define FONT_WIDTH 8
|
|
|
|
#define FONT_HEIGHT 16
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2004-02-07 01:28:00 +03:00
|
|
|
#define WINBITMAP(w) (((GrafPtr)(w))->portBits)
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2004-02-07 01:28:00 +03:00
|
|
|
#define ASCII_1_MASK 0x00FF0000
|
|
|
|
#define ASCII_2_MASK 0x000000FF
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2004-02-07 01:28:00 +03:00
|
|
|
const RGBColor black = {0, 0, 0};
|
|
|
|
const RGBColor white = {0xFFFF, 0xFFFF, 0xFFFF};
|
|
|
|
const RGBColor medGrey = {0xCCCC, 0xCCCC, 0xCCCC};
|
2008-02-06 01:57:43 +03:00
|
|
|
const RGBColor ltGrey = {0xEEEE, 0xEEEE, 0xEEEE};
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2002-11-18 19:42:57 +03:00
|
|
|
class bx_macintosh_gui_c : public bx_gui_c {
|
2002-10-25 01:07:56 +04:00
|
|
|
public:
|
2002-11-18 19:42:57 +03:00
|
|
|
bx_macintosh_gui_c (void) {}
|
2002-10-25 01:07:56 +04:00
|
|
|
DECLARE_GUI_VIRTUAL_METHODS()
|
|
|
|
};
|
|
|
|
|
|
|
|
// declare one instance of the gui object and call macro to insert the
|
|
|
|
// plugin code
|
2002-11-18 19:42:57 +03:00
|
|
|
static bx_macintosh_gui_c *theGui = NULL;
|
2002-10-25 01:07:56 +04:00
|
|
|
IMPLEMENT_GUI_PLUGIN_CODE(macintosh)
|
|
|
|
|
2002-12-12 18:29:45 +03:00
|
|
|
#define LOG_THIS theGui->
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
// GLOBALS
|
2004-02-08 21:11:45 +03:00
|
|
|
|
2004-02-07 01:28:00 +03:00
|
|
|
WindowPtr win, toolwin, fullwin, backdrop, hidden, SouixWin;
|
|
|
|
SInt16 gOldMBarHeight;
|
|
|
|
bx_bool menubarVisible = true, cursorVisible = true;
|
|
|
|
RgnHandle mBarRgn, cnrRgn;
|
|
|
|
unsigned mouse_button_state = 0;
|
|
|
|
CTabHandle gCTable;
|
|
|
|
PixMapHandle gTile;
|
|
|
|
BitMap *vgafont[256];
|
|
|
|
Rect srcTextRect, srcTileRect;
|
|
|
|
Point scrCenter = {320, 240};
|
|
|
|
Ptr KCHR;
|
|
|
|
short gheaderbar_y;
|
|
|
|
Point prevPt;
|
|
|
|
unsigned width, height, gMinTop, gMaxTop, gLeft;
|
|
|
|
GWorldPtr gOffWorld;
|
2004-02-08 21:11:45 +03:00
|
|
|
Ptr gMyBuffer;
|
2012-10-14 22:29:44 +04:00
|
|
|
static unsigned disp_bpp=8;
|
2004-02-08 21:11:45 +03:00
|
|
|
static EventModifiers oldMods = 0;
|
2008-01-26 03:00:31 +03:00
|
|
|
static unsigned int text_rows=25, text_cols=80;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
// HEADERBAR STUFF
|
2004-02-07 01:28:00 +03:00
|
|
|
int numPixMaps = 0, toolPixMaps = 0;
|
|
|
|
unsigned bx_bitmap_left_xorigin = 2; // pixels from left
|
|
|
|
unsigned bx_bitmap_right_xorigin = 2; // pixels from right
|
|
|
|
//PixMapHandle bx_pixmap[BX_MAX_PIXMAPS];
|
|
|
|
CIconHandle bx_cicn[BX_MAX_PIXMAPS];
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
struct {
|
2004-02-07 01:28:00 +03:00
|
|
|
CIconHandle cicn;
|
|
|
|
// PixMapHandle pm;
|
|
|
|
unsigned xdim;
|
|
|
|
unsigned ydim;
|
|
|
|
unsigned xorigin;
|
|
|
|
unsigned yorigin;
|
|
|
|
unsigned alignment;
|
|
|
|
void (*f)(void);
|
2001-04-10 05:04:59 +04:00
|
|
|
} bx_tool_pixmap[BX_MAX_PIXMAPS];
|
|
|
|
|
|
|
|
// Event handlers
|
2001-04-10 06:10:09 +04:00
|
|
|
BX_CPP_INLINE void HandleKey(EventRecord *event, Bit32u keyState);
|
|
|
|
BX_CPP_INLINE void HandleToolClick(Point where);
|
2001-04-10 05:04:59 +04:00
|
|
|
void HandleMenuChoice(long menuChoice);
|
2001-04-10 06:10:09 +04:00
|
|
|
BX_CPP_INLINE void HandleClick(EventRecord *event);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
// Update routines
|
|
|
|
void UpdateWindow(WindowPtr window);
|
|
|
|
void UpdateRgn(RgnHandle rgn);
|
|
|
|
|
|
|
|
// Show/hide UI elements
|
|
|
|
void HidePointer(void);
|
|
|
|
void ShowPointer(void);
|
|
|
|
void HideTools(void);
|
|
|
|
void ShowTools(void);
|
|
|
|
void HideMenubar(void);
|
|
|
|
void ShowMenubar(void);
|
|
|
|
void HideConsole(void);
|
|
|
|
void ShowConsole(void);
|
|
|
|
|
|
|
|
// Initialisation
|
|
|
|
void FixWindow(void);
|
|
|
|
void MacPanic(void);
|
|
|
|
void InitToolbox(void);
|
|
|
|
void CreateTile(void);
|
|
|
|
void CreateMenus(void);
|
|
|
|
void CreateWindows(void);
|
|
|
|
void CreateKeyMap(void);
|
|
|
|
void CreateVGAFont(void);
|
2004-02-08 21:11:45 +03:00
|
|
|
BitMap *CreateBitMap(unsigned width, unsigned height);
|
2001-04-10 05:04:59 +04:00
|
|
|
PixMapHandle CreatePixMap(unsigned left, unsigned top, unsigned width,
|
2004-02-07 01:28:00 +03:00
|
|
|
unsigned height, unsigned depth, CTabHandle clut);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
//this routine moves the initial window position so that it is entirely onscreen
|
|
|
|
//it is needed for os 8.x with appearance managaer
|
|
|
|
void FixWindow(void)
|
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
RgnHandle wStruct;
|
|
|
|
Region *wRgn;
|
|
|
|
CWindowRecord *thing;
|
|
|
|
Rect wRect;
|
|
|
|
RgnHandle tStruct;
|
|
|
|
Region *tRgn;
|
|
|
|
Rect tRect;
|
|
|
|
short MinVal;
|
|
|
|
|
|
|
|
thing = (CWindowRecord *)win;
|
|
|
|
wStruct = thing->strucRgn;
|
|
|
|
wRgn = (Region *)*wStruct;
|
|
|
|
wRect = wRgn->rgnBBox;
|
|
|
|
|
|
|
|
thing = (CWindowRecord *)toolwin;
|
|
|
|
tStruct = thing->strucRgn;
|
|
|
|
tRgn = (Region *)*tStruct;
|
|
|
|
tRect = tRgn->rgnBBox;
|
|
|
|
|
|
|
|
if (wRect.left < 2)
|
|
|
|
{
|
|
|
|
gLeft = gLeft + (2 - wRect.left);
|
|
|
|
}
|
|
|
|
|
|
|
|
MinVal = tRect.bottom+2;
|
|
|
|
//MinVal = MinVal + GetMBarHeight();
|
|
|
|
|
|
|
|
if (wRect.top < MinVal)
|
|
|
|
{
|
|
|
|
// gMinTop = gMinTop + (MinVal - wRect.top);
|
|
|
|
gMaxTop = gMaxTop + (MinVal - wRect.top);
|
|
|
|
}
|
|
|
|
|
|
|
|
MoveWindow(win, gLeft, gMaxTop, false);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void MacPanic(void)
|
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
StopAlert(200, NULL);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void InitToolbox(void)
|
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
InitGraf(&qd.thePort);
|
|
|
|
InitWindows();
|
|
|
|
InitMenus();
|
|
|
|
InitDialogs(nil);
|
|
|
|
InitCursor();
|
|
|
|
MaxApplZone();
|
|
|
|
// Initialise the toolbox
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void CreateTile(void)
|
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
GDHandle saveDevice;
|
|
|
|
CGrafPtr savePort;
|
|
|
|
OSErr err;
|
|
|
|
unsigned long p_f;
|
2012-10-14 22:29:44 +04:00
|
|
|
long theRowBytes = ((((long) (disp_bpp==24?32:(((disp_bpp+1)>>1)<<1)) * ((long) (srcTileRect.right-srcTileRect.left)) + 31) >> 5) << 2);
|
2008-02-16 01:05:43 +03:00
|
|
|
|
|
|
|
//if (SIM->get_param_bool(BXPN_PRIVATE_COLORMAP)->get())
|
|
|
|
//{
|
|
|
|
|
|
|
|
GetGWorld(&savePort, &saveDevice);
|
2012-10-14 22:29:44 +04:00
|
|
|
switch (disp_bpp) {
|
2004-02-08 21:11:45 +03:00
|
|
|
case 1:
|
|
|
|
p_f = k1MonochromePixelFormat;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
p_f = k2IndexedPixelFormat;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
p_f = k4IndexedPixelFormat;
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
p_f = k8IndexedPixelFormat;
|
|
|
|
break;
|
|
|
|
case 15:
|
|
|
|
p_f = k16LE555PixelFormat;
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
p_f = k16LE565PixelFormat;
|
|
|
|
break;
|
|
|
|
case 24:
|
|
|
|
//p_f = k24BGRPixelFormat;
|
|
|
|
//break;
|
|
|
|
case 32:
|
|
|
|
p_f = k32ARGBPixelFormat;//k32BGRAPixelFormat;
|
|
|
|
break;
|
2008-02-16 01:05:43 +03:00
|
|
|
}
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
BX_ASSERT((gMyBuffer = (Ptr)malloc(theRowBytes * (srcTileRect.bottom - srcTileRect.top))) != NULL);
|
|
|
|
err = QTNewGWorldFromPtr(&gOffWorld, p_f,
|
2012-10-14 22:29:44 +04:00
|
|
|
&srcTileRect, disp_bpp>8 ? NULL : gCTable, NULL, keepLocal, gMyBuffer, theRowBytes);
|
2008-02-16 01:05:43 +03:00
|
|
|
if (err != noErr || gOffWorld == NULL)
|
|
|
|
BX_PANIC(("mac: can't create gOffWorld; err=%hd", err));
|
2004-02-08 21:11:45 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
SetGWorld(gOffWorld, NULL);
|
|
|
|
RGBForeColor(&black);
|
|
|
|
RGBBackColor(&white);
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
gTile = GetGWorldPixMap(gOffWorld);
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
if (gTile != NULL)
|
|
|
|
{
|
|
|
|
NoPurgePixels(gTile);
|
|
|
|
if (!LockPixels(gTile))
|
|
|
|
BX_ERROR(("mac: can't LockPixels gTile"));
|
|
|
|
if ((**gTile).pixelType != RGBDirect && (**gTile).pmTable != gCTable)
|
|
|
|
{
|
|
|
|
DisposeCTable(gCTable);
|
|
|
|
gCTable = (**gTile).pmTable;
|
|
|
|
}
|
|
|
|
|
|
|
|
(**gCTable).ctFlags |= 0x4000; //use palette manager indexes
|
|
|
|
CTabChanged(gCTable);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
BX_PANIC(("mac: can't create gTile"));
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
SetGWorld(savePort, saveDevice);
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
/*}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gOffWorld = NULL;
|
|
|
|
gTile = CreatePixMap(0, 0, srcTileRect.right, srcTileRect.bottom, 8, gCTable);
|
|
|
|
if (gTile == NULL)
|
|
|
|
BX_PANIC(("mac: can't create gTile"));
|
|
|
|
}*/
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void CreateMenus(void)
|
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
Handle menu;
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
menu = GetNewMBar(rMBarID); // get our menus from resource
|
2008-02-06 01:57:43 +03:00
|
|
|
if (menu != nil)
|
2004-02-08 21:11:45 +03:00
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
SetMenuBar(menu);
|
|
|
|
DisposeHandle(menu);
|
|
|
|
AppendResMenu(GetMenuHandle(mApple), 'DRVR'); // add apple menu items
|
|
|
|
DrawMenuBar();
|
2004-02-08 21:11:45 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
BX_PANIC(("can't create menu"));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void CreateWindows(void)
|
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
int l, t, r, b;
|
|
|
|
Rect winRect;
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
SetRect(&winRect, 0, 0, qd.screenBits.bounds.right, qd.screenBits.bounds.bottom);
|
|
|
|
backdrop = NewWindow(NULL, &winRect, "\p", false, plainDBox, (WindowPtr)-1, false, 0);
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
width = 640;
|
|
|
|
height = 480;
|
|
|
|
gLeft = 4;
|
|
|
|
gMinTop = 44;
|
|
|
|
gMaxTop = 44 + gheaderbar_y;
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
l = (qd.screenBits.bounds.right - width)/2;
|
|
|
|
r = l + width;
|
|
|
|
t = (qd.screenBits.bounds.bottom - height)/2;
|
|
|
|
b = t + height;
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
SetRect(&winRect, 0, 20, qd.screenBits.bounds.right, 22+gheaderbar_y);
|
|
|
|
toolwin = NewCWindow(NULL, &winRect, "\pMacBochs 586", true, floatProc,
|
|
|
|
(WindowPtr)-1, false, 0);
|
|
|
|
if (toolwin == NULL)
|
|
|
|
BX_PANIC(("mac: can't create tool window"));
|
|
|
|
// Create a moveable tool window for the "headerbar"
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
SetRect(&winRect, l, t, r, b);
|
|
|
|
fullwin = NewCWindow(NULL, &winRect, "\p", false, plainDBox, (WindowPtr)-1, false, 1);
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
SetRect(&winRect, gLeft, gMaxTop, gLeft+width, gMaxTop+height);
|
|
|
|
win = NewCWindow(NULL, &winRect, "\pMacBochs 586", true, documentProc,
|
|
|
|
(WindowPtr)-1, true, 1);
|
|
|
|
if (win == NULL)
|
|
|
|
BX_PANIC(("mac: can't create emulator window"));
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
FixWindow();
|
2004-02-07 01:28:00 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
hidden = fullwin;
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
HiliteWindow(win, true);
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
SetPort(win);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2017-01-15 14:44:43 +03:00
|
|
|
// MACINTOSH implementation of the bx_gui_c methods (see nogui.cc for details)
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2012-03-03 16:41:24 +04:00
|
|
|
void bx_macintosh_gui_c::specific_init(int argc, char **argv, unsigned headerbar_y)
|
2008-02-06 01:57:43 +03:00
|
|
|
{
|
2013-12-29 16:56:52 +04:00
|
|
|
put("MACGUI");
|
2008-02-16 01:05:43 +03:00
|
|
|
InitToolbox();
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
//SouixWin = FrontWindow();
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
atexit(MacPanic);
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
gheaderbar_y = headerbar_y;
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
CreateKeyMap();
|
2004-02-07 01:28:00 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
gCTable = GetCTable(128);
|
2004-02-08 21:11:45 +03:00
|
|
|
BX_ASSERT (gCTable != NULL);
|
2008-02-06 01:57:43 +03:00
|
|
|
CTabChanged(gCTable); //(*gCTable)->ctSeed = GetCTSeed();
|
2008-02-16 01:05:43 +03:00
|
|
|
SetRect(&srcTextRect, 0, 0, FONT_WIDTH, FONT_HEIGHT);
|
2012-03-03 16:41:24 +04:00
|
|
|
SetRect(&srcTileRect, 0, 0, x_tilesize, y_tilesize);
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
CreateMenus();
|
|
|
|
CreateVGAFont();
|
|
|
|
CreateTile();
|
|
|
|
CreateWindows();
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
GetMouse(&prevPt);
|
|
|
|
SetEventMask(everyEvent);
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
SIOUXSettings.setupmenus = false;
|
|
|
|
SIOUXSettings.autocloseonquit = true;
|
|
|
|
SIOUXSettings.asktosaveonclose = false;
|
|
|
|
SIOUXSettings.standalone = false;
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
UNUSED(argc);
|
|
|
|
UNUSED(argv);
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
//HideWindow(SouixWin);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// HandleKey()
|
|
|
|
//
|
|
|
|
// Handles keyboard-related events.
|
|
|
|
|
2001-04-10 06:10:09 +04:00
|
|
|
BX_CPP_INLINE void HandleKey(EventRecord *event, Bit32u keyState)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2004-02-07 01:28:00 +03:00
|
|
|
UInt32 key;
|
|
|
|
UInt32 trans;
|
2008-02-16 01:05:43 +03:00
|
|
|
static UInt32 transState = 0;
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
key = event->message & charCodeMask;
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
if (event->modifiers & cmdKey)
|
|
|
|
{
|
|
|
|
HandleMenuChoice(MenuKey(key));
|
|
|
|
}
|
|
|
|
//else if (FrontWindow() == SouixWin)
|
|
|
|
//{
|
|
|
|
// SIOUXHandleOneEvent(event);
|
|
|
|
//}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* if (event->modifiers & shiftKey)
|
|
|
|
DEV_kbd_gen_scancode(BX_KEY_SHIFT_L | keyState);
|
|
|
|
if (event->modifiers & controlKey)
|
|
|
|
DEV_kbd_gen_scancode(BX_KEY_CTRL_L | keyState);
|
|
|
|
if (event->modifiers & optionKey)
|
|
|
|
DEV_kbd_gen_scancode(BX_KEY_ALT_L | keyState);*/
|
|
|
|
|
|
|
|
key = (event->message & keyCodeMask) >> 8;
|
|
|
|
|
|
|
|
trans = KeyTranslate(KCHR, key, &transState);
|
|
|
|
if ((trans == BX_KEY_PRINT) && ((oldMods & optionKey) || (oldMods & rightOptionKey)))
|
|
|
|
trans = BX_KEY_ALT_SYSREQ;
|
|
|
|
if ((trans == BX_KEY_PAUSE) && ((oldMods & controlKey) || (oldMods & rightControlKey)))
|
|
|
|
trans = BX_KEY_CTRL_BREAK;
|
|
|
|
|
|
|
|
// KeyTranslate maps Mac virtual key codes to any type of character code
|
|
|
|
// you like (in this case, Bochs key codes). Much nicer than a huge switch
|
|
|
|
// statement!
|
|
|
|
|
|
|
|
if (trans > 0)
|
|
|
|
DEV_kbd_gen_scancode(trans | keyState);
|
|
|
|
|
|
|
|
/* if (event->modifiers & shiftKey)
|
|
|
|
DEV_kbd_gen_scancode(BX_KEY_SHIFT_L | BX_KEY_RELEASED);
|
|
|
|
if (event->modifiers & controlKey)
|
|
|
|
DEV_kbd_gen_scancode(BX_KEY_CTRL_L | BX_KEY_RELEASED);
|
|
|
|
if (event->modifiers & optionKey)
|
|
|
|
DEV_kbd_gen_scancode(BX_KEY_ALT_L | BX_KEY_RELEASED);*/
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// HandleToolClick()
|
|
|
|
//
|
|
|
|
// Handles mouse clicks in the Bochs tool window
|
|
|
|
|
2001-04-10 06:10:09 +04:00
|
|
|
BX_CPP_INLINE void HandleToolClick(Point where)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
unsigned i;
|
|
|
|
int xorigin;
|
|
|
|
Rect bounds;
|
|
|
|
|
|
|
|
SetPort(toolwin);
|
|
|
|
GlobalToLocal(&where);
|
|
|
|
for (i=0; i<toolPixMaps; i++)
|
|
|
|
{
|
|
|
|
if (bx_tool_pixmap[i].alignment == BX_GRAVITY_LEFT)
|
|
|
|
xorigin = bx_tool_pixmap[i].xorigin;
|
|
|
|
else
|
|
|
|
xorigin = toolwin->portRect.right - bx_tool_pixmap[i].xorigin;
|
|
|
|
SetRect(&bounds, xorigin, 0, xorigin+32, 32);
|
|
|
|
if (PtInRect(where, &bounds))
|
|
|
|
bx_tool_pixmap[i].f();
|
|
|
|
}
|
|
|
|
theGui->show_headerbar();
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2001-04-10 06:10:09 +04:00
|
|
|
BX_CPP_INLINE void ResetPointer(void)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
|
|
|
#if 0
|
2008-02-16 01:05:43 +03:00
|
|
|
CursorDevice *theMouse;
|
|
|
|
if (true)
|
|
|
|
{
|
|
|
|
theMouse = NULL;
|
|
|
|
CrsrDevNextDevice(&theMouse);
|
|
|
|
CrsrDevMoveTo(theMouse, (long)scrCenter.h, (long)scrCenter.v);
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define MouseCur 0x082C
|
|
|
|
#define MouseTemp 0x0828
|
|
|
|
#define MouseNew 0x08CE
|
|
|
|
#define MouseAttached 0x08CF
|
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
*(Point *)MouseCur = scrCenter;
|
|
|
|
*(Point *)MouseTemp = scrCenter;
|
|
|
|
*(Ptr)MouseNew = *(Ptr)MouseAttached;
|
|
|
|
//*(char *)CrsrNew = 0xFF;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// HandleClick()
|
|
|
|
//
|
|
|
|
// Handles mouse click events.
|
|
|
|
|
|
|
|
|
|
|
|
void HandleMenuChoice(long menuChoice)
|
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
OSErr err = noErr;
|
|
|
|
short item, menu, i;
|
|
|
|
short daRefNum;
|
|
|
|
Rect bounds;
|
|
|
|
Str255 daName;
|
|
|
|
WindowRef newWindow;
|
|
|
|
DialogPtr theDlog;
|
|
|
|
|
|
|
|
item = LoWord(menuChoice);
|
|
|
|
menu = HiWord(menuChoice);
|
|
|
|
|
|
|
|
switch(menu) {
|
|
|
|
case mApple:
|
|
|
|
switch(item) {
|
|
|
|
case iAbout:
|
|
|
|
theDlog = GetNewDialog(128, NULL, (WindowPtr)-1);
|
|
|
|
ModalDialog(NULL, &i);
|
|
|
|
DisposeDialog(theDlog);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
GetMenuItemText(GetMenuHandle(mApple), item, daName);
|
|
|
|
daRefNum = OpenDeskAcc(daName);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case mFile:
|
|
|
|
switch(item) {
|
|
|
|
case iQuit:
|
|
|
|
BX_PANIC(("User terminated"));
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case mBochs:
|
|
|
|
switch(item) {
|
|
|
|
case iFloppy:
|
|
|
|
DiskEject(1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case iCursor:
|
|
|
|
if (cursorVisible)
|
|
|
|
HidePointer();
|
|
|
|
else
|
|
|
|
ShowPointer();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case iTool:
|
|
|
|
if (IsWindowVisible(toolwin))
|
|
|
|
HideTools();
|
|
|
|
else
|
|
|
|
ShowTools();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case iMenuBar:
|
|
|
|
if (menubarVisible)
|
|
|
|
HideMenubar();
|
|
|
|
else
|
|
|
|
ShowMenubar();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case iFullScreen:
|
|
|
|
if (cursorVisible || IsWindowVisible(toolwin) || menubarVisible)
|
|
|
|
{
|
|
|
|
if (cursorVisible)
|
|
|
|
HidePointer();
|
|
|
|
if (menubarVisible)
|
|
|
|
HideMenubar();
|
|
|
|
if (IsWindowVisible(toolwin))
|
|
|
|
HideTools();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!cursorVisible)
|
|
|
|
ShowPointer();
|
|
|
|
if (!menubarVisible)
|
|
|
|
ShowMenubar();
|
|
|
|
if (!IsWindowVisible(toolwin))
|
|
|
|
ShowTools();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case iConsole:
|
|
|
|
if (IsWindowVisible(SouixWin))
|
|
|
|
HideConsole();
|
|
|
|
else
|
|
|
|
ShowConsole();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case iSnapshot:
|
|
|
|
// the following will break if snapshot is not last bitmap button instantiated
|
|
|
|
bx_tool_pixmap[toolPixMaps-1].f();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
HiliteMenu(0);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2001-04-10 06:10:09 +04:00
|
|
|
BX_CPP_INLINE void HandleClick(EventRecord *event)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
short part;
|
|
|
|
WindowPtr whichWindow;
|
|
|
|
Rect dRect;
|
|
|
|
|
|
|
|
part = FindWindow(event->where, &whichWindow);
|
|
|
|
|
|
|
|
switch(part)
|
|
|
|
{
|
|
|
|
case inContent:
|
|
|
|
if (whichWindow == win)
|
|
|
|
{
|
|
|
|
if (win != FrontWindow())
|
|
|
|
SelectWindow(win);
|
|
|
|
if (event->modifiers & cmdKey)
|
|
|
|
mouse_button_state |= 0x02;
|
|
|
|
else
|
|
|
|
mouse_button_state |= 0x01;
|
|
|
|
}
|
|
|
|
else if (whichWindow == toolwin)
|
|
|
|
{
|
|
|
|
HiliteWindow(win, true);
|
|
|
|
HandleToolClick(event->where);
|
|
|
|
}
|
|
|
|
else if (whichWindow == backdrop)
|
|
|
|
{
|
|
|
|
SelectWindow(win);
|
|
|
|
}
|
|
|
|
else if (whichWindow == SouixWin)
|
|
|
|
{
|
|
|
|
SelectWindow(SouixWin);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case inDrag:
|
|
|
|
dRect = qd.screenBits.bounds;
|
|
|
|
if (IsWindowVisible(toolwin))
|
|
|
|
dRect.top = gMaxTop;
|
|
|
|
DragWindow(whichWindow, event->where, &dRect);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case inMenuBar:
|
|
|
|
HandleMenuChoice(MenuSelect(event->where));
|
|
|
|
break;
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2008-02-06 01:57:43 +03:00
|
|
|
void UpdateWindow(WindowPtr window)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
GrafPtr oldPort;
|
|
|
|
Rect box;
|
|
|
|
|
|
|
|
GetPort(&oldPort);
|
|
|
|
|
|
|
|
SetPort(window);
|
|
|
|
BeginUpdate(window);
|
|
|
|
|
|
|
|
if (window == win)
|
|
|
|
{
|
|
|
|
box = window->portRect;
|
|
|
|
DEV_vga_redraw_area(box.left, box.top, box.right, box.bottom);
|
|
|
|
}
|
|
|
|
else if (window == backdrop)
|
|
|
|
{
|
|
|
|
box = window->portRect;
|
|
|
|
FillRect(&box, &qd.black);
|
|
|
|
}
|
|
|
|
else if (window == toolwin)
|
|
|
|
{
|
|
|
|
theGui->show_headerbar();
|
|
|
|
}
|
|
|
|
|
|
|
|
EndUpdate(window);
|
|
|
|
SetPort(oldPort);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2002-11-18 19:42:57 +03:00
|
|
|
void bx_macintosh_gui_c::handle_events(void)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
EventRecord event;
|
|
|
|
Point mousePt;
|
|
|
|
int dx, dy;
|
|
|
|
int oldMods1=0;
|
2004-02-08 21:11:45 +03:00
|
|
|
EventModifiers newMods;
|
2008-02-16 01:05:43 +03:00
|
|
|
unsigned curstate;
|
|
|
|
GrafPtr oldport;
|
|
|
|
|
|
|
|
curstate = mouse_button_state; //so we can compare the old and the new mouse state
|
|
|
|
|
|
|
|
if (WaitNextEvent(everyEvent, &event, SLEEP_TIME, NULL))
|
|
|
|
{
|
|
|
|
switch(event.what)
|
|
|
|
{
|
|
|
|
case nullEvent:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case mouseDown:
|
|
|
|
HandleClick(&event);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case mouseUp:
|
|
|
|
if (event.modifiers & cmdKey)
|
|
|
|
mouse_button_state &= ~0x02;
|
|
|
|
else
|
|
|
|
mouse_button_state &= ~0x01;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case keyDown:
|
|
|
|
case autoKey:
|
|
|
|
oldMods1 = event.modifiers;
|
|
|
|
HandleKey(&event, BX_KEY_PRESSED);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case keyUp:
|
|
|
|
event.modifiers = oldMods1;
|
|
|
|
HandleKey(&event, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case updateEvt:
|
|
|
|
if ((WindowPtr)event.message == SouixWin)
|
|
|
|
SIOUXHandleOneEvent(&event);
|
|
|
|
else
|
|
|
|
UpdateWindow((WindowPtr)event.message);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case diskEvt:
|
|
|
|
floppyA_handler();
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2004-02-08 21:11:45 +03:00
|
|
|
else if (oldMods != (newMods = (event.modifiers & 0xfe00)))
|
|
|
|
{
|
|
|
|
if ((newMods ^ oldMods) & shiftKey)
|
|
|
|
DEV_kbd_gen_scancode(BX_KEY_SHIFT_L | ((newMods & shiftKey)?BX_KEY_PRESSED:BX_KEY_RELEASED));
|
|
|
|
if ((newMods ^ oldMods) & alphaLock)
|
|
|
|
DEV_kbd_gen_scancode(BX_KEY_CAPS_LOCK | ((newMods & alphaLock)?BX_KEY_PRESSED:BX_KEY_RELEASED));
|
|
|
|
if ((newMods ^ oldMods) & optionKey)
|
|
|
|
DEV_kbd_gen_scancode(BX_KEY_ALT_L | ((newMods & optionKey)?BX_KEY_PRESSED:BX_KEY_RELEASED));
|
|
|
|
if ((newMods ^ oldMods) & controlKey)
|
|
|
|
DEV_kbd_gen_scancode(BX_KEY_CTRL_L | ((newMods & controlKey)?BX_KEY_PRESSED:BX_KEY_RELEASED));
|
|
|
|
if ((newMods ^ oldMods) & rightShiftKey)
|
|
|
|
DEV_kbd_gen_scancode(BX_KEY_SHIFT_R | ((newMods & rightShiftKey)?BX_KEY_PRESSED:BX_KEY_RELEASED));
|
|
|
|
if ((newMods ^ oldMods) & rightOptionKey)
|
|
|
|
DEV_kbd_gen_scancode(BX_KEY_ALT_R | ((newMods & rightOptionKey)?BX_KEY_PRESSED:BX_KEY_RELEASED));
|
|
|
|
if ((newMods ^ oldMods) & rightControlKey)
|
|
|
|
DEV_kbd_gen_scancode(BX_KEY_CTRL_R | ((newMods & rightControlKey)?BX_KEY_PRESSED:BX_KEY_RELEASED));
|
|
|
|
oldMods = newMods;
|
|
|
|
}
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
GetPort(&oldport);
|
|
|
|
SetPort(win);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
GetMouse(&mousePt);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
//if mouse has moved, or button has changed state
|
2008-02-16 01:05:43 +03:00
|
|
|
if ((!EqualPt(mousePt, prevPt)) || (curstate != mouse_button_state))
|
|
|
|
{
|
|
|
|
dx = mousePt.h - prevPt.h;
|
|
|
|
dy = prevPt.v - mousePt.v;
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2012-06-21 21:33:37 +04:00
|
|
|
DEV_mouse_motion(dx, dy, 0, mouse_button_state, 0);
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
if (!cursorVisible)
|
|
|
|
{
|
|
|
|
SetPt(&scrCenter, 320, 240);
|
|
|
|
LocalToGlobal(&scrCenter);
|
|
|
|
ResetPointer(); //next getmouse should be 320, 240
|
|
|
|
SetPt(&mousePt, 320, 240);
|
|
|
|
}
|
|
|
|
}
|
2004-02-07 01:28:00 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
prevPt = mousePt;
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
SetPort(oldport);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2002-11-18 19:42:57 +03:00
|
|
|
void bx_macintosh_gui_c::flush(void)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
// an opportunity to make the Window Manager happy.
|
|
|
|
// not needed on the macintosh....
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2002-11-18 19:42:57 +03:00
|
|
|
void bx_macintosh_gui_c::clear_screen(void)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
SetPort(win);
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
RGBForeColor(&black);
|
|
|
|
RGBBackColor(&white);
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
FillRect(&win->portRect, &qd.black);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2002-11-18 19:42:57 +03:00
|
|
|
void bx_macintosh_gui_c::text_update(Bit8u *old_text, Bit8u *new_text,
|
2008-01-26 03:00:31 +03:00
|
|
|
unsigned long cursor_x, unsigned long cursor_y,
|
2012-01-22 16:22:03 +04:00
|
|
|
bx_vga_tminfo_t *tm_info)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
int i;
|
|
|
|
unsigned char achar;
|
|
|
|
int x, y;
|
|
|
|
static int previ;
|
|
|
|
int cursori;
|
|
|
|
Rect destRect;
|
|
|
|
RGBColor fgColor, bgColor;
|
|
|
|
GrafPtr oldPort;
|
|
|
|
unsigned nchars;
|
|
|
|
OSErr theError;
|
|
|
|
|
|
|
|
GetPort(&oldPort);
|
|
|
|
|
|
|
|
SetPort(win);
|
|
|
|
|
|
|
|
//current cursor position
|
|
|
|
cursori = (cursor_y * text_cols + cursor_x) * 2;
|
2004-02-07 01:28:00 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
// Number of characters on screen, variable number of rows
|
|
|
|
nchars = text_cols * text_rows;
|
|
|
|
|
|
|
|
for (i=0; i<nchars*2; i+=2)
|
|
|
|
{
|
|
|
|
if (i == cursori || i == previ || new_text[i] != old_text[i] || new_text[i+1] != old_text[i+1])
|
|
|
|
{
|
|
|
|
achar = new_text[i];
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
// fgColor = (**gCTable).ctTable[new_text[i+1] & 0x0F].rgb;
|
|
|
|
// bgColor = (**gCTable).ctTable[(new_text[i+1] & 0xF0) >> 4].rgb;
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
// RGBForeColor(&fgColor);
|
|
|
|
// RGBBackColor(&bgColor);
|
|
|
|
|
|
|
|
if (SIM->get_param_bool(BXPN_PRIVATE_COLORMAP)->get())
|
|
|
|
{
|
|
|
|
PmForeColor(new_text[i+1] & 0x0F);
|
|
|
|
PmBackColor((new_text[i+1] & 0xF0) >> 4);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fgColor = (**gCTable).ctTable[new_text[i+1] & 0x0F].rgb;
|
|
|
|
bgColor = (**gCTable).ctTable[(new_text[i+1] & 0xF0) >> 4].rgb;
|
|
|
|
|
|
|
|
RGBForeColor(&fgColor);
|
|
|
|
RGBBackColor(&bgColor);
|
|
|
|
}
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
x = ((i/2) % text_cols)*FONT_WIDTH;
|
|
|
|
y = ((i/2) / text_cols)*FONT_HEIGHT;
|
|
|
|
|
|
|
|
SetRect(&destRect, x, y, x+FONT_WIDTH, y+FONT_HEIGHT);
|
|
|
|
|
|
|
|
CopyBits(vgafont[achar], &WINBITMAP(win),
|
|
|
|
&srcTextRect, &destRect, srcCopy, NULL);
|
|
|
|
if ((theError = QDError()) != noErr)
|
|
|
|
BX_ERROR(("mac: CopyBits returned %hd", theError));
|
|
|
|
|
|
|
|
if (i == cursori) //invert the current cursor block
|
|
|
|
{
|
|
|
|
InvertRect(&destRect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//previous cursor position
|
|
|
|
previ = cursori;
|
|
|
|
|
|
|
|
SetPort(oldPort);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
int bx_macintosh_gui_c::get_clipboard_text(Bit8u **bytes, Bit32s *nbytes)
|
2002-03-16 14:30:06 +03:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
int bx_macintosh_gui_c::set_clipboard_text(char *text_snapshot, Bit32u len)
|
2002-03-15 19:45:10 +03:00
|
|
|
{
|
2002-03-16 14:30:06 +03:00
|
|
|
return 0;
|
2002-03-15 19:45:10 +03:00
|
|
|
}
|
|
|
|
|
2012-10-14 22:29:44 +04:00
|
|
|
bx_bool bx_macintosh_gui_c::palette_change(Bit8u index, Bit8u red, Bit8u green, Bit8u blue)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
PaletteHandle thePal, oldpal;
|
|
|
|
GDHandle saveDevice;
|
|
|
|
CGrafPtr savePort;
|
2004-02-08 21:11:45 +03:00
|
|
|
GrafPtr oldPort;
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
/*if (gOffWorld != NULL) //(SIM->get_param_bool(BXPN_PRIVATE_COLORMAP)->get())
|
2004-02-08 21:11:45 +03:00
|
|
|
{
|
|
|
|
GetGWorld(&savePort, &saveDevice);
|
|
|
|
|
|
|
|
SetGWorld(gOffWorld, NULL);
|
|
|
|
}*/
|
2008-02-16 01:05:43 +03:00
|
|
|
|
2004-02-08 21:11:45 +03:00
|
|
|
if ((**gTile).pixelType != RGBDirect)
|
|
|
|
{
|
|
|
|
GetPort(&oldPort);
|
|
|
|
SetPort(win);
|
2004-02-07 01:28:00 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
(**gCTable).ctTable[index].value = index;
|
|
|
|
(**gCTable).ctTable[index].rgb.red = (red << 8);
|
|
|
|
(**gCTable).ctTable[index].rgb.green = (green << 8);
|
|
|
|
(**gCTable).ctTable[index].rgb.blue = (blue << 8);
|
2004-02-07 01:28:00 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
SetEntries(index, index, (**gCTable).ctTable);
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
CTabChanged(gCTable);
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2004-02-08 21:11:45 +03:00
|
|
|
SetPort(oldPort);
|
|
|
|
}
|
2008-02-16 01:05:43 +03:00
|
|
|
|
|
|
|
/*if (gOffWorld != NULL) //(SIM->get_param_bool(BXPN_PRIVATE_COLORMAP)->get())
|
2004-02-08 21:11:45 +03:00
|
|
|
SetGWorld(savePort, saveDevice);*/
|
2008-02-16 01:05:43 +03:00
|
|
|
|
2006-02-22 00:35:09 +03:00
|
|
|
if (SIM->get_param_bool(BXPN_PRIVATE_COLORMAP)->get())
|
2004-02-08 21:11:45 +03:00
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
thePal = NewPalette(index, gCTable, pmTolerant, 0x5000);
|
|
|
|
oldpal = GetPalette(win);
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
SetPalette(win, thePal, false);
|
|
|
|
SetPalette(fullwin, thePal, false);
|
|
|
|
SetPalette(hidden, thePal, false);
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2004-02-08 21:11:45 +03:00
|
|
|
return(1);
|
|
|
|
}
|
2004-02-07 01:28:00 +03:00
|
|
|
|
2004-02-08 21:11:45 +03:00
|
|
|
return((**gTile).pixelType != RGBDirect);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2002-11-18 19:42:57 +03:00
|
|
|
void bx_macintosh_gui_c::graphics_tile_update(Bit8u *tile, unsigned x0, unsigned y0)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
Rect destRect;
|
|
|
|
OSErr theError;
|
|
|
|
Ptr theBaseAddr;
|
|
|
|
GrafPtr oldPort;
|
|
|
|
/*GDHandle saveDevice;
|
|
|
|
CGrafPtr savePort;
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
GetGWorld(&savePort, &saveDevice);
|
2004-02-07 01:28:00 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
SetGWorld(gOffWorld, NULL); */
|
|
|
|
GetPort(&oldPort);
|
|
|
|
SetPort(win);
|
|
|
|
destRect = srcTileRect;
|
|
|
|
OffsetRect(&destRect, x0, y0);
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2004-02-08 21:11:45 +03:00
|
|
|
//(**gTile).baseAddr = (Ptr)tile;
|
|
|
|
if ((theBaseAddr = GetPixBaseAddr(gTile)) == NULL)
|
|
|
|
BX_PANIC(("mac: gTile has NULL baseAddr (offscreen buffer purged)"));
|
2012-10-14 22:29:44 +04:00
|
|
|
else if (disp_bpp == 24 || disp_bpp == 32) {
|
|
|
|
for (unsigned iY = 0; iY < (srcTileRect.bottom-srcTileRect.top); iY++) {
|
2004-02-08 21:11:45 +03:00
|
|
|
Bit8u *iA = ((Bit8u *)theBaseAddr) + iY * GetPixRowBytes(gTile);
|
2012-10-14 22:29:44 +04:00
|
|
|
for (unsigned iX = 0; iX < (srcTileRect.right-srcTileRect.left); iX++) {
|
|
|
|
iA[iX*4 + 3] = tile[((srcTileRect.right-srcTileRect.left)*iY+iX)*(disp_bpp>>3)];
|
|
|
|
iA[iX*4 + 2] = tile[((srcTileRect.right-srcTileRect.left)*iY+iX)*(disp_bpp>>3) + 1];
|
|
|
|
iA[iX*4 + 1] = tile[((srcTileRect.right-srcTileRect.left)*iY+iX)*(disp_bpp>>3) + 2];
|
|
|
|
iA[iX*4] = disp_bpp == 24 ? 0 : tile[((srcTileRect.right-srcTileRect.left)*iY+iX)*4 + 3];
|
2004-02-08 21:11:45 +03:00
|
|
|
}
|
|
|
|
}
|
2012-10-14 22:29:44 +04:00
|
|
|
} else {
|
2004-02-08 21:11:45 +03:00
|
|
|
BlockMoveData(tile, theBaseAddr, (srcTileRect.bottom-srcTileRect.top) * GetPixRowBytes(gTile));
|
2012-10-14 22:29:44 +04:00
|
|
|
}
|
2004-02-08 21:11:45 +03:00
|
|
|
RGBForeColor(&black);
|
|
|
|
RGBBackColor(&white);
|
2008-02-16 01:05:43 +03:00
|
|
|
CopyBits(GetPortBitMapForCopyBits(gOffWorld), &WINBITMAP(win),
|
2004-02-07 01:28:00 +03:00
|
|
|
&srcTileRect, &destRect, srcCopy, NULL);
|
2004-02-08 21:11:45 +03:00
|
|
|
if ((theError = QDError()) != noErr)
|
|
|
|
BX_ERROR(("mac: CopyBits returned %hd", theError));
|
|
|
|
SetPort(oldPort);
|
2004-02-07 01:28:00 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
//SetGWorld(savePort, saveDevice);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2003-06-28 12:04:31 +04:00
|
|
|
void bx_macintosh_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight, unsigned fwidth, unsigned bpp)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2004-02-08 21:11:45 +03:00
|
|
|
if ((bpp != 1) && (bpp != 2) && (bpp != 4) && (bpp != 8) && (bpp != 15) && (bpp != 16) && (bpp != 24) && (bpp != 32)) {
|
2008-02-16 01:05:43 +03:00
|
|
|
BX_PANIC(("%d bpp graphics mode not supported yet", bpp));
|
2003-06-28 12:04:31 +04:00
|
|
|
}
|
2012-10-14 22:29:44 +04:00
|
|
|
guest_textmode = (fheight > 0);
|
|
|
|
guest_xres = x;
|
|
|
|
guest_yres = y;
|
|
|
|
guest_bpp = bpp;
|
|
|
|
if (bpp != disp_bpp) {
|
2004-02-08 21:11:45 +03:00
|
|
|
free(gMyBuffer);
|
|
|
|
if ((**gTile).pixelType == RGBDirect)
|
|
|
|
gCTable = GetCTable(128);
|
|
|
|
DisposeGWorld(gOffWorld);
|
2012-10-14 22:29:44 +04:00
|
|
|
disp_bpp = bpp;
|
2004-02-08 21:11:45 +03:00
|
|
|
CreateTile();
|
|
|
|
}
|
2012-10-14 22:29:44 +04:00
|
|
|
if (guest_textmode) {
|
2008-02-16 01:05:43 +03:00
|
|
|
text_cols = x / fwidth;
|
|
|
|
text_rows = y / fheight;
|
|
|
|
if (fwidth != 8) {
|
|
|
|
x = x * 8 / fwidth;
|
|
|
|
}
|
|
|
|
if (fheight != 16) {
|
|
|
|
y = y * 16 / fheight;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (x != width || y != height)
|
|
|
|
{
|
|
|
|
SizeWindow(win, x, y, false);
|
|
|
|
SizeWindow(fullwin, x, y, false);
|
|
|
|
SizeWindow(hidden, x, y, false);
|
|
|
|
width = x;
|
|
|
|
height = y;
|
2002-04-20 11:19:35 +04:00
|
|
|
}
|
2004-08-15 23:27:15 +04:00
|
|
|
|
|
|
|
host_xres = x;
|
|
|
|
host_yres = y;
|
|
|
|
host_bpp = bpp;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// ::CREATE_BITMAP()
|
|
|
|
//
|
|
|
|
// rewritten by tim senecal to use the cicn (color icon) resources instead
|
|
|
|
|
2002-11-18 19:42:57 +03:00
|
|
|
unsigned bx_macintosh_gui_c::create_bitmap(const unsigned char *bmap, unsigned xdim, unsigned ydim)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
unsigned i;
|
|
|
|
unsigned char *data;
|
|
|
|
long row_bytes, bytecount;
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
bx_cicn[numPixMaps] = GetCIcon(numPixMaps+128);
|
2004-02-08 21:11:45 +03:00
|
|
|
BX_ASSERT(bx_cicn[numPixMaps]);
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
numPixMaps++;
|
2004-02-07 01:28:00 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
return(numPixMaps-1);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2002-11-18 19:42:57 +03:00
|
|
|
unsigned bx_macintosh_gui_c::headerbar_bitmap(unsigned bmap_id, unsigned alignment, void (*f)(void))
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
unsigned hb_index;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
toolPixMaps++;
|
|
|
|
hb_index = toolPixMaps-1;
|
|
|
|
//bx_tool_pixmap[hb_index].pm = bx_pixmap[bmap_id];
|
|
|
|
bx_tool_pixmap[hb_index].cicn = bx_cicn[bmap_id];
|
|
|
|
bx_tool_pixmap[hb_index].alignment = alignment;
|
|
|
|
bx_tool_pixmap[hb_index].f = f;
|
|
|
|
|
|
|
|
if (alignment == BX_GRAVITY_LEFT)
|
|
|
|
{
|
|
|
|
bx_tool_pixmap[hb_index].xorigin = bx_bitmap_left_xorigin;
|
|
|
|
bx_tool_pixmap[hb_index].yorigin = 0;
|
|
|
|
// bx_bitmap_left_xorigin += (**bx_pixmap[bmap_id]).bounds.right;
|
|
|
|
bx_bitmap_left_xorigin += 34;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// bx_bitmap_right_xorigin += (**bx_pixmap[bmap_id]).bounds.right;
|
|
|
|
bx_bitmap_right_xorigin += 34;
|
|
|
|
bx_tool_pixmap[hb_index].xorigin = bx_bitmap_right_xorigin;
|
|
|
|
bx_tool_pixmap[hb_index].yorigin = 0;
|
|
|
|
}
|
|
|
|
return(hb_index);
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2002-11-18 19:42:57 +03:00
|
|
|
void bx_macintosh_gui_c::show_headerbar(void)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
Rect destRect;
|
|
|
|
int i, xorigin;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
SetPort(toolwin);
|
|
|
|
RGBForeColor(&medGrey);
|
|
|
|
FillRect(&toolwin->portRect, &qd.black);
|
|
|
|
for (i=0; i<toolPixMaps; i++)
|
|
|
|
{
|
|
|
|
if (bx_tool_pixmap[i].alignment == BX_GRAVITY_LEFT)
|
|
|
|
xorigin = bx_tool_pixmap[i].xorigin;
|
|
|
|
else
|
|
|
|
xorigin = toolwin->portRect.right - bx_tool_pixmap[i].xorigin;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
SetRect(&destRect, xorigin, 0, xorigin+32, 32);
|
|
|
|
|
|
|
|
//changed, simply plot the cicn for that button, in the prescribed rectangle
|
|
|
|
PlotCIcon(&destRect, bx_tool_pixmap[i].cicn);
|
|
|
|
}
|
|
|
|
RGBForeColor(&black);
|
|
|
|
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2002-11-18 19:42:57 +03:00
|
|
|
void bx_macintosh_gui_c::replace_bitmap(unsigned hbar_id, unsigned bmap_id)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
//bx_tool_pixmap[hbar_id].pm = bx_pixmap[bmap_id];
|
|
|
|
bx_tool_pixmap[hbar_id].cicn = bx_cicn[bmap_id];
|
|
|
|
show_headerbar();
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2002-11-18 19:42:57 +03:00
|
|
|
void bx_macintosh_gui_c::exit(void)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
if (!menubarVisible)
|
|
|
|
ShowMenubar(); // Make the menubar visible again
|
|
|
|
InitCursor();
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
2002-11-18 19:42:57 +03:00
|
|
|
void bx_macintosh_gui_c::snapshot_handler(void)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
PicHandle ScreenShot;
|
|
|
|
long val;
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
SetPort(win);
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
ScreenShot = OpenPicture(&win->portRect);
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
CopyBits(&win->portBits, &win->portBits, &win->portRect, &win->portRect, srcCopy, NULL);
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
ClosePicture();
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
val = ZeroScrap();
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
HLock((Handle)ScreenShot);
|
|
|
|
PutScrap(GetHandleSize((Handle)ScreenShot), 'PICT', *ScreenShot);
|
|
|
|
HUnlock((Handle)ScreenShot);
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
KillPicture(ScreenShot);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// UpdateRgn()
|
|
|
|
//
|
|
|
|
// Updates the screen after the menubar and round corners have been hidden
|
|
|
|
|
|
|
|
void UpdateRgn(RgnHandle rgn)
|
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
WindowPtr window;
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
window = FrontWindow();
|
|
|
|
PaintBehind(window, rgn);
|
|
|
|
CalcVisBehind(window, rgn);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// HidePointer()
|
|
|
|
//
|
|
|
|
// Hides the Mac mouse pointer
|
|
|
|
|
|
|
|
void HidePointer()
|
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
HiliteMenu(0);
|
|
|
|
HideCursor();
|
|
|
|
SetPort(win);
|
|
|
|
SetPt(&scrCenter, 320, 240);
|
|
|
|
LocalToGlobal(&scrCenter);
|
|
|
|
ResetPointer();
|
|
|
|
GetMouse(&prevPt);
|
|
|
|
cursorVisible = false;
|
|
|
|
CheckItem(GetMenuHandle(mBochs), iCursor, false);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// ShowPointer()
|
|
|
|
//
|
|
|
|
// Shows the Mac mouse pointer
|
|
|
|
|
|
|
|
void ShowPointer()
|
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
InitCursor();
|
|
|
|
cursorVisible = true;
|
|
|
|
CheckItem(GetMenuHandle(mBochs), iCursor, true);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// HideTools()
|
|
|
|
//
|
|
|
|
// Hides the Bochs toolbar
|
|
|
|
|
|
|
|
void HideTools()
|
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
HideWindow(toolwin);
|
|
|
|
if (menubarVisible)
|
|
|
|
{
|
|
|
|
MoveWindow(win, gLeft, gMinTop, false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
MoveWindow(hidden, gLeft, gMinTop, false);
|
|
|
|
}
|
|
|
|
CheckItem(GetMenuHandle(mBochs), iTool, false);
|
|
|
|
HiliteWindow(win, true);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// ShowTools()
|
|
|
|
//
|
|
|
|
// Shows the Bochs toolbar
|
|
|
|
|
|
|
|
void ShowTools()
|
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
if (menubarVisible)
|
|
|
|
{
|
|
|
|
MoveWindow(win, gLeft, gMaxTop, false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
MoveWindow(hidden, gLeft, gMaxTop, false);
|
|
|
|
}
|
|
|
|
ShowWindow(toolwin);
|
|
|
|
BringToFront(toolwin);
|
|
|
|
SelectWindow(toolwin);
|
|
|
|
HiliteWindow(win, true);
|
|
|
|
//theGui->show_headerbar();
|
|
|
|
CheckItem(GetMenuHandle(mBochs), iTool, true);
|
|
|
|
HiliteWindow(win, true);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// HideMenubar()
|
|
|
|
//
|
|
|
|
// Hides the menubar (obviously)
|
|
|
|
|
|
|
|
void HideMenubar()
|
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
Rect mBarRect;
|
|
|
|
RgnHandle grayRgn;
|
|
|
|
|
|
|
|
grayRgn = LMGetGrayRgn();
|
|
|
|
gOldMBarHeight = GetMBarHeight();
|
|
|
|
LMSetMBarHeight(0);
|
|
|
|
mBarRgn = NewRgn();
|
|
|
|
mBarRect = qd.screenBits.bounds;
|
|
|
|
mBarRect.bottom = mBarRect.top + gOldMBarHeight;
|
|
|
|
RectRgn(mBarRgn, &mBarRect);
|
|
|
|
UnionRgn(grayRgn, mBarRgn, grayRgn);
|
|
|
|
UpdateRgn(mBarRgn);
|
|
|
|
|
|
|
|
cnrRgn = NewRgn();
|
|
|
|
RectRgn(cnrRgn, &qd.screenBits.bounds);
|
|
|
|
DiffRgn(cnrRgn, grayRgn, cnrRgn);
|
|
|
|
UnionRgn(grayRgn, cnrRgn, grayRgn);
|
|
|
|
UpdateRgn(mBarRgn);
|
|
|
|
|
|
|
|
HideWindow(win);
|
|
|
|
ShowWindow(backdrop);
|
|
|
|
SelectWindow(backdrop);
|
|
|
|
hidden = win;
|
|
|
|
win = fullwin;
|
|
|
|
ShowWindow(win);
|
|
|
|
|
|
|
|
SelectWindow(win);
|
|
|
|
menubarVisible = false;
|
|
|
|
CheckItem(GetMenuHandle(mBochs), iMenuBar, false);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// ShowMenubar()
|
|
|
|
//
|
|
|
|
// Makes the menubar visible again so other programs will display correctly.
|
|
|
|
|
|
|
|
void ShowMenubar()
|
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
RgnHandle grayRgn;
|
|
|
|
GrafPtr savePort;
|
|
|
|
|
|
|
|
grayRgn = LMGetGrayRgn();
|
|
|
|
LMSetMBarHeight(gOldMBarHeight);
|
|
|
|
DiffRgn(grayRgn, mBarRgn, grayRgn);
|
|
|
|
DisposeRgn(mBarRgn);
|
|
|
|
DrawMenuBar();
|
|
|
|
|
|
|
|
GetPort(&savePort);
|
|
|
|
SetPort(LMGetWMgrPort());
|
|
|
|
SetClip(cnrRgn);
|
|
|
|
FillRgn(cnrRgn, &qd.black);
|
|
|
|
SetPort(savePort);
|
|
|
|
DiffRgn(grayRgn, cnrRgn, grayRgn);
|
|
|
|
DisposeRgn(cnrRgn);
|
|
|
|
|
|
|
|
HideWindow(backdrop);
|
|
|
|
win = hidden;
|
|
|
|
hidden = fullwin;
|
|
|
|
HideWindow(hidden);
|
|
|
|
ShowWindow(win);
|
|
|
|
HiliteWindow(win, true);
|
|
|
|
|
|
|
|
menubarVisible = true;
|
|
|
|
CheckItem(GetMenuHandle(mBochs), iMenuBar, true);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void HideConsole()
|
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
HideWindow(SouixWin);
|
|
|
|
CheckItem(GetMenuHandle(mBochs), iConsole, false);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ShowConsole()
|
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
ShowWindow(SouixWin);
|
|
|
|
SelectWindow(SouixWin);
|
|
|
|
CheckItem(GetMenuHandle(mBochs), iConsole, true);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// CreateKeyMap()
|
|
|
|
//
|
|
|
|
// Create a KCHR data structure to map Mac virtual key codes to Bochs key codes
|
|
|
|
|
|
|
|
void CreateKeyMap(void)
|
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
const unsigned char KCHRHeader [258] = { 0, 1 };
|
|
|
|
|
|
|
|
const unsigned char KCHRTable [130] = {
|
|
|
|
0,
|
|
|
|
1,
|
|
|
|
BX_KEY_A,
|
|
|
|
BX_KEY_S,
|
|
|
|
BX_KEY_D,
|
|
|
|
BX_KEY_F,
|
|
|
|
BX_KEY_H,
|
|
|
|
BX_KEY_G,
|
|
|
|
BX_KEY_Z,
|
|
|
|
BX_KEY_X,
|
|
|
|
BX_KEY_C,
|
|
|
|
BX_KEY_V,
|
|
|
|
BX_KEY_LEFT_BACKSLASH,
|
|
|
|
BX_KEY_B,
|
|
|
|
BX_KEY_Q,
|
|
|
|
BX_KEY_W,
|
|
|
|
BX_KEY_E,
|
|
|
|
BX_KEY_R,
|
|
|
|
BX_KEY_Y,
|
|
|
|
BX_KEY_T,
|
|
|
|
BX_KEY_1,
|
|
|
|
BX_KEY_2,
|
|
|
|
BX_KEY_3,
|
|
|
|
BX_KEY_4,
|
|
|
|
BX_KEY_6,
|
|
|
|
BX_KEY_5,
|
|
|
|
BX_KEY_EQUALS,
|
|
|
|
BX_KEY_9,
|
|
|
|
BX_KEY_7,
|
|
|
|
BX_KEY_MINUS,
|
|
|
|
BX_KEY_8,
|
|
|
|
BX_KEY_0,
|
|
|
|
BX_KEY_RIGHT_BRACKET,
|
|
|
|
BX_KEY_O,
|
|
|
|
BX_KEY_U,
|
|
|
|
BX_KEY_LEFT_BRACKET,
|
|
|
|
BX_KEY_I,
|
|
|
|
BX_KEY_P,
|
|
|
|
BX_KEY_ENTER,
|
|
|
|
BX_KEY_L,
|
|
|
|
BX_KEY_J,
|
|
|
|
BX_KEY_SINGLE_QUOTE,
|
|
|
|
BX_KEY_K,
|
|
|
|
BX_KEY_SEMICOLON,
|
|
|
|
BX_KEY_BACKSLASH,
|
|
|
|
BX_KEY_COMMA,
|
|
|
|
BX_KEY_SLASH,
|
|
|
|
BX_KEY_N,
|
|
|
|
BX_KEY_M,
|
|
|
|
BX_KEY_PERIOD,
|
|
|
|
BX_KEY_TAB,
|
|
|
|
BX_KEY_SPACE,
|
|
|
|
BX_KEY_GRAVE,
|
|
|
|
BX_KEY_BACKSPACE,
|
|
|
|
BX_KEY_KP_ENTER,
|
|
|
|
BX_KEY_ESC,
|
|
|
|
0, // 0x36 (record button)
|
|
|
|
0, // 0x37 (cmd key)
|
|
|
|
0, // 0x38 (left shift)
|
|
|
|
0, // 0x39 (caps lock)
|
|
|
|
0, // 0x3A (left option/alt)
|
|
|
|
0, // 0x3B (left ctrl)
|
|
|
|
0, // 0x3C (right shift)
|
|
|
|
0, // 0x3D (right option/alt)
|
|
|
|
0, // 0x3E (right ctrl)
|
|
|
|
0, // 0x3F (fn key -- laptops)
|
|
|
|
0, // 0x40
|
2004-02-08 21:11:45 +03:00
|
|
|
BX_KEY_KP_DELETE, // KP_PERIOD
|
2008-02-16 01:05:43 +03:00
|
|
|
0, // 0x42 (move right/multiply)
|
|
|
|
BX_KEY_KP_MULTIPLY,
|
|
|
|
0, // 0x44
|
|
|
|
BX_KEY_KP_ADD,
|
|
|
|
0, // 0x46 (move left/add)
|
2004-02-08 21:11:45 +03:00
|
|
|
BX_KEY_NUM_LOCK,
|
2008-02-16 01:05:43 +03:00
|
|
|
0, // 0x48 (move down/equals)
|
|
|
|
0, // 0x49
|
|
|
|
0, // 0x4A
|
|
|
|
BX_KEY_KP_DIVIDE,
|
|
|
|
BX_KEY_KP_ENTER,
|
|
|
|
0, // 0x4D (move up/divide)
|
|
|
|
BX_KEY_KP_SUBTRACT,
|
|
|
|
0, // 0x4F
|
|
|
|
0, // 0x50
|
2004-02-08 21:11:45 +03:00
|
|
|
BX_KEY_EQUALS, // 0x51 (kp equals)
|
|
|
|
BX_KEY_KP_INSERT, // 0x52 (kp 0)
|
|
|
|
BX_KEY_KP_END, // 0x53 (kp 1)
|
2008-02-16 01:05:43 +03:00
|
|
|
BX_KEY_KP_DOWN, // 0x54 (kp 2)
|
2004-02-08 21:11:45 +03:00
|
|
|
BX_KEY_KP_PAGE_DOWN, // 0x55 (kp 3)
|
2008-02-16 01:05:43 +03:00
|
|
|
BX_KEY_KP_LEFT, // 0x56 (kp 4)
|
|
|
|
BX_KEY_KP_5,
|
|
|
|
BX_KEY_KP_RIGHT, // 0x58 (kp 6)
|
2004-02-08 21:11:45 +03:00
|
|
|
BX_KEY_KP_HOME, // 0x59 (kp 7)
|
2008-02-16 01:05:43 +03:00
|
|
|
0, // 0x5A
|
|
|
|
BX_KEY_KP_UP, // 0x5B (kp 8)
|
2004-02-08 21:11:45 +03:00
|
|
|
BX_KEY_KP_PAGE_UP, // 0x5C (kp 9)
|
2008-02-16 01:05:43 +03:00
|
|
|
0, // 0x5D
|
|
|
|
0, // 0x5E
|
|
|
|
0, // 0x5F
|
|
|
|
BX_KEY_F5,
|
|
|
|
BX_KEY_F6,
|
|
|
|
BX_KEY_F7,
|
|
|
|
BX_KEY_F3,
|
|
|
|
BX_KEY_F8,
|
|
|
|
BX_KEY_F9,
|
|
|
|
0, // 0x66
|
|
|
|
BX_KEY_F11,
|
|
|
|
0, // 0x68
|
2004-02-08 21:11:45 +03:00
|
|
|
BX_KEY_PRINT, // 0x69 (print screen)
|
2008-02-16 01:05:43 +03:00
|
|
|
0, // 0x6A
|
2004-02-08 21:11:45 +03:00
|
|
|
BX_KEY_SCRL_LOCK, // 0x6B (scroll lock)
|
2008-02-16 01:05:43 +03:00
|
|
|
0, // 0x6C
|
|
|
|
BX_KEY_F10,
|
|
|
|
BX_KEY_MENU, // 0x6E
|
|
|
|
BX_KEY_F12,
|
|
|
|
0, // 0x70
|
2004-02-08 21:11:45 +03:00
|
|
|
BX_KEY_PAUSE, // 0x71 (pause)
|
2008-02-16 01:05:43 +03:00
|
|
|
BX_KEY_INSERT,
|
|
|
|
BX_KEY_HOME,
|
|
|
|
BX_KEY_PAGE_UP,
|
|
|
|
BX_KEY_DELETE,
|
|
|
|
BX_KEY_F4,
|
|
|
|
BX_KEY_END,
|
|
|
|
BX_KEY_F2,
|
|
|
|
BX_KEY_PAGE_DOWN,
|
|
|
|
BX_KEY_F1,
|
|
|
|
BX_KEY_LEFT,
|
|
|
|
BX_KEY_RIGHT,
|
|
|
|
BX_KEY_DOWN,
|
|
|
|
BX_KEY_UP
|
|
|
|
};
|
|
|
|
|
|
|
|
KCHR = NewPtrClear(390);
|
|
|
|
if (KCHR == NULL)
|
|
|
|
BX_PANIC(("mac: can't allocate memory for key map"));
|
|
|
|
|
|
|
|
BlockMove(KCHRHeader, KCHR, sizeof(KCHRHeader));
|
|
|
|
BlockMove(KCHRTable, Ptr(KCHR + sizeof(KCHRHeader)), sizeof(KCHRTable));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// CreateVGAFont()
|
|
|
|
//
|
|
|
|
// Create an array of PixMaps for the PC screen font
|
|
|
|
|
|
|
|
void CreateVGAFont(void)
|
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
int i, x;
|
|
|
|
unsigned char *fontData, curPixel;
|
|
|
|
long row_bytes, bytecount;
|
|
|
|
|
|
|
|
for (i=0; i<256; i++)
|
|
|
|
{
|
|
|
|
vgafont[i] = CreateBitMap(FONT_WIDTH, FONT_HEIGHT);
|
|
|
|
row_bytes = (*(vgafont[i])).rowBytes;
|
|
|
|
bytecount = row_bytes * FONT_HEIGHT;
|
|
|
|
fontData = (unsigned char *)NewPtrClear(bytecount);
|
|
|
|
|
|
|
|
for (x=0; x<16; x++)
|
|
|
|
{
|
|
|
|
//curPixel = ~(bx_vgafont[i].data[x]);
|
|
|
|
curPixel = (bx_vgafont[i].data[x]);
|
|
|
|
fontData[x*row_bytes] = reverse_bitorder(curPixel);
|
|
|
|
}
|
|
|
|
|
|
|
|
vgafont[i]->baseAddr = Ptr(fontData);
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// CreateBitMap()
|
|
|
|
// Allocate a new bitmap and fill in the fields with appropriate
|
|
|
|
// values.
|
|
|
|
|
2004-02-07 01:28:00 +03:00
|
|
|
BitMap *CreateBitMap(unsigned width, unsigned height)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
BitMap *bm;
|
|
|
|
long row_bytes;
|
|
|
|
|
|
|
|
row_bytes = ((width + 31) >> 5) << 2;
|
|
|
|
bm = (BitMap *)calloc(1, sizeof(BitMap));
|
|
|
|
if (bm == NULL)
|
|
|
|
BX_PANIC(("mac: can't allocate memory for pixmap"));
|
|
|
|
SetRect(&bm->bounds, 0, 0, width, height);
|
|
|
|
bm->rowBytes = row_bytes;
|
|
|
|
// Quickdraw allocates a new color table by default, but we want to
|
|
|
|
// use one we created earlier.
|
|
|
|
|
|
|
|
return bm;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// CreatePixMap()
|
|
|
|
// Allocate a new pixmap handle and fill in the fields with appropriate
|
|
|
|
// values.
|
|
|
|
|
|
|
|
PixMapHandle CreatePixMap(unsigned left, unsigned top, unsigned width,
|
2004-02-07 01:28:00 +03:00
|
|
|
unsigned height, unsigned depth, CTabHandle clut)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
PixMapHandle pm;
|
|
|
|
long row_bytes;
|
|
|
|
|
|
|
|
row_bytes = (((long) depth * ((long) width) + 31) >> 5) << 2;
|
|
|
|
pm = NewPixMap();
|
|
|
|
if (pm == NULL)
|
|
|
|
BX_PANIC(("mac: can't allocate memory for pixmap"));
|
|
|
|
(**pm).bounds.left = left;
|
|
|
|
(**pm).bounds.top = top;
|
|
|
|
(**pm).bounds.right = left+width;
|
|
|
|
(**pm).bounds.bottom = top+height;
|
|
|
|
(**pm).pixelSize = depth;
|
|
|
|
(**pm).rowBytes = row_bytes | 0x8000;
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
DisposeCTable((**pm).pmTable);
|
|
|
|
(**pm).pmTable = clut;
|
|
|
|
// Quickdraw allocates a new color table by default, but we want to
|
|
|
|
// use one we created earlier.
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
return pm;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
void bx_macintosh_gui_c::mouse_enabled_changed_specific (bx_bool val)
|
2001-06-23 07:18:14 +04:00
|
|
|
{
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
2008-02-16 01:05:43 +03:00
|
|
|
|
2002-11-19 08:47:45 +03:00
|
|
|
#endif /* if BX_WITH_MACOS */
|