2007-03-23 11:30:22 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
2011-02-25 01:05:47 +03:00
|
|
|
// $Id$
|
2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2021-01-30 21:32:52 +03:00
|
|
|
// Copyright (C) 2001-2021 The Bochs Project
|
2001-09-26 04:31:41 +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-09-26 04:31:41 +04:00
|
|
|
|
2001-09-26 04:32:34 +04:00
|
|
|
// carbon.cc -- bochs GUI file for MacOS X with Carbon API
|
2001-09-26 04:31:41 +04:00
|
|
|
// written by David Batterham <drbatter@progsoc.uts.edu.au>
|
|
|
|
// with contributions from Tim Senecal
|
2001-09-26 04:32:34 +04:00
|
|
|
// port to Carbon API by Emmanuel Maillard <e.rsz@libertysurf.fr>
|
2002-10-18 15:46:19 +04:00
|
|
|
// Carbon polishing by Jeremy Parsons (Br'fin) <brefin@mac.com>
|
2002-09-30 18:03:20 +04:00
|
|
|
// slight overhaul of Carbon key event, graphics and window handling
|
2002-11-14 04:40:11 +03:00
|
|
|
// and SIM->notify alert support by Chris Thomas <cjack@cjack.com>
|
2001-09-26 04:31:41 +04:00
|
|
|
|
2002-10-25 01:07:56 +04:00
|
|
|
// Define BX_PLUGGABLE in files that can be compiled into plugins. For
|
2008-02-07 21:28:50 +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-09-26 04:31:41 +04:00
|
|
|
// BOCHS INCLUDES
|
|
|
|
#include "bochs.h"
|
2009-02-23 14:06:53 +03:00
|
|
|
#include "keymap.h"
|
2004-06-19 19:20:15 +04:00
|
|
|
#include "iodev.h"
|
2010-02-26 17:18:19 +03:00
|
|
|
|
|
|
|
#include "param_names.h"
|
2002-11-19 08:47:45 +03:00
|
|
|
|
|
|
|
#if BX_WITH_CARBON
|
|
|
|
|
2001-09-26 04:31:41 +04:00
|
|
|
#include "icon_bochs.h"
|
|
|
|
#include "font/vga.bitmap.h"
|
2002-10-27 02:06:37 +04:00
|
|
|
#include "bxversion.h"
|
2001-09-26 04:31:41 +04:00
|
|
|
|
|
|
|
// MAC OS INCLUDES
|
2001-09-26 04:32:34 +04:00
|
|
|
#include <Carbon/Carbon.h>
|
|
|
|
#include <ApplicationServices/ApplicationServices.h>
|
2001-09-26 04:31:41 +04:00
|
|
|
|
2021-01-30 21:32:52 +03:00
|
|
|
// NOTE about use of Boolean versus bool:
|
2002-10-25 15:44:41 +04:00
|
|
|
// Boolean is defined as unsigned char in the Carbon headers, so when
|
|
|
|
// you are talking to the Carbon API, it expects to find Boolean variables
|
2021-01-30 21:32:52 +03:00
|
|
|
// and pointers to Booleans. The rest of Bochs uses bool to represent
|
2002-10-25 15:44:41 +04:00
|
|
|
// booleans, which are defined to be 32 bit unsigned, so member function
|
2021-01-30 21:32:52 +03:00
|
|
|
// definitions and booleans outside this file will be bools. "Boolean"
|
2002-10-25 15:44:41 +04:00
|
|
|
// should only be used in Carbon specific code such as in this file.
|
|
|
|
|
2001-09-26 04:31:41 +04:00
|
|
|
// CONSTANTS
|
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
#define rMBarID 128
|
|
|
|
#define mApple 128
|
|
|
|
#define iAbout 1
|
|
|
|
#define mFile 129
|
|
|
|
#define iQuit 1
|
|
|
|
#define mEdit 130
|
|
|
|
#define iUndo 1
|
|
|
|
#define iCut 3
|
|
|
|
#define iCopy 4
|
|
|
|
#define iPaste 5
|
|
|
|
#define iClear 6
|
|
|
|
#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
|
2001-09-26 04:31:41 +04:00
|
|
|
|
2002-10-18 15:46:19 +04:00
|
|
|
enum {
|
2002-11-14 04:40:11 +03:00
|
|
|
RESET_TOOL_BUTTON = 5,
|
|
|
|
CONFIGURE_TOOL_BUTTON,
|
|
|
|
SNAPSHOT_TOOL_BUTTON,
|
|
|
|
PASTE_TOOL_BUTTON,
|
|
|
|
COPY_TOOL_BUTTON,
|
|
|
|
USER_TOOL_BUTTON
|
2002-10-18 15:46:19 +04:00
|
|
|
};
|
|
|
|
|
2002-03-09 05:40:25 +03:00
|
|
|
const MenuCommand kCommandFloppy = FOUR_CHAR_CODE ('FLPY');
|
|
|
|
const MenuCommand kCommandCursor = FOUR_CHAR_CODE ('CRSR');
|
|
|
|
const MenuCommand kCommandTool = FOUR_CHAR_CODE ('TOOL');
|
|
|
|
const MenuCommand kCommandMenuBar = FOUR_CHAR_CODE ('MENU');
|
|
|
|
const MenuCommand kCommandFullScreen = FOUR_CHAR_CODE ('SCRN');
|
|
|
|
const MenuCommand kCommandSnapshot = FOUR_CHAR_CODE ('SNAP');
|
|
|
|
const MenuCommand kCommandReset = FOUR_CHAR_CODE ('RSET');
|
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
#define SLEEP_TIME 0 // Number of ticks to surrender the processor during a WaitNextEvent()
|
2001-09-26 04:31:41 +04:00
|
|
|
// Change this to 15 or higher if you don't want Bochs to hog the processor!
|
|
|
|
|
2007-03-23 11:30:22 +03:00
|
|
|
int font_width;
|
|
|
|
int font_height;
|
2001-09-26 04:31:41 +04:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
#define WINBITMAP(w) GetPortBitMapForCopyBits(GetWindowPort(w)) // (((GrafPtr)(w))->portBits)
|
2001-09-26 04:31:41 +04:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
#define ASCII_1_MASK 0x00FF0000
|
|
|
|
#define ASCII_2_MASK 0x000000FF
|
2001-09-26 04:31:41 +04:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
const RGBColor black = {0, 0, 0};
|
|
|
|
const RGBColor white = {0xFFFF, 0xFFFF, 0xFFFF};
|
|
|
|
const RGBColor medGrey = {0xCCCC, 0xCCCC, 0xCCCC};
|
|
|
|
const RGBColor ltGrey = {0xEEEE, 0xEEEE, 0xEEEE};
|
2001-09-26 04:31:41 +04:00
|
|
|
|
|
|
|
// GLOBALS
|
2001-09-26 04:32:34 +04:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
WindowPtr win, toolwin, fullwin, backdrop, hidden, SouixWin;
|
|
|
|
WindowGroupRef fullwinGroup;
|
|
|
|
SInt16 gOldMBarHeight;
|
|
|
|
Boolean menubarVisible = true, cursorVisible = true;
|
|
|
|
Boolean windowUpdatesPending = true, mouseMoved = false;
|
|
|
|
RgnHandle mBarRgn, cnrRgn;
|
|
|
|
unsigned mouse_button_state = 0;
|
|
|
|
CTabHandle gCTable;
|
|
|
|
PixMapHandle gTile;
|
|
|
|
BitMap *vgafont[256];
|
|
|
|
Rect srcTextRect, srcTileRect;
|
|
|
|
Point scrCenter = {300, 240};
|
|
|
|
Ptr KCHR;
|
|
|
|
short gheaderbar_y;
|
|
|
|
Point prevPt;
|
|
|
|
unsigned width, height, gMinTop, gMaxTop, gLeft;
|
|
|
|
GWorldPtr gOffWorld;
|
2003-11-08 09:46:03 +03:00
|
|
|
Ptr gMyBuffer;
|
2002-11-14 04:40:11 +03:00
|
|
|
ProcessSerialNumber gProcessSerNum;
|
2012-10-14 22:29:44 +04:00
|
|
|
static unsigned disp_bpp=8;
|
2003-11-17 07:21:16 +03:00
|
|
|
static EventModifiers oldMods = 0;
|
2008-01-26 03:00:31 +03:00
|
|
|
static unsigned int text_rows=25, text_cols=80;
|
2001-09-26 04:31:41 +04:00
|
|
|
|
2002-10-18 15:46:19 +04:00
|
|
|
enum {
|
2002-11-14 04:40:11 +03:00
|
|
|
TEXT_MODE,
|
|
|
|
GRAPHIC_MODE
|
2002-10-18 15:46:19 +04:00
|
|
|
} last_screen_state = TEXT_MODE, screen_state = TEXT_MODE;
|
|
|
|
|
2001-09-26 04:31:41 +04:00
|
|
|
// HEADERBAR STUFF
|
2002-10-18 15:46:19 +04:00
|
|
|
#define TOOL_SPACING 10
|
|
|
|
#define TOOL_MARGIN_SPACE 4
|
2002-11-14 04:40:11 +03:00
|
|
|
int numPixMaps = 0, toolPixMaps = 0;
|
|
|
|
unsigned bx_bitmap_left_xorigin = 2+TOOL_SPACING; // pixels from left
|
|
|
|
unsigned bx_bitmap_right_xorigin = 2+TOOL_SPACING; // pixels from right
|
|
|
|
//PixMapHandle bx_pixmap[BX_MAX_PIXMAPS];
|
|
|
|
CIconHandle bx_cicn[BX_MAX_PIXMAPS];
|
2001-09-26 04:31:41 +04:00
|
|
|
|
2005-07-24 11:25:02 +04:00
|
|
|
struct __bx_tool_pixmap {
|
2002-11-14 04:40:11 +03:00
|
|
|
// CIconHandle cicn;
|
|
|
|
// PixMapHandle pm;
|
|
|
|
ControlRef control;
|
|
|
|
unsigned xdim;
|
|
|
|
unsigned ydim;
|
|
|
|
unsigned xorigin;
|
|
|
|
unsigned yorigin;
|
|
|
|
unsigned alignment;
|
|
|
|
void (*f)(void);
|
2001-09-26 04:31:41 +04:00
|
|
|
} bx_tool_pixmap[BX_MAX_PIXMAPS];
|
|
|
|
|
2002-03-09 05:40:25 +03:00
|
|
|
// Carbon Event Handlers
|
2002-10-18 15:46:19 +04:00
|
|
|
pascal OSStatus CEvtHandleWindowToolCommand (EventHandlerCallRef nextHandler, EventRef theEvent, void* userData);
|
2002-03-09 05:40:25 +03:00
|
|
|
pascal OSStatus CEvtHandleWindowToolUpdate (EventHandlerCallRef nextHandler, EventRef theEvent, void* userData);
|
|
|
|
pascal OSStatus CEvtHandleWindowBackdropUpdate (EventHandlerCallRef nextHandler, EventRef theEvent, void* userData);
|
|
|
|
pascal OSStatus CEvtHandleWindowEmulatorClick (EventHandlerCallRef nextHandler, EventRef theEvent, void* userData);
|
|
|
|
pascal OSStatus CEvtHandleWindowEmulatorUpdate (EventHandlerCallRef nextHandler, EventRef theEvent, void* userData);
|
|
|
|
pascal OSStatus CEvtHandleWindowEmulatorKeys (EventHandlerCallRef nextHandler, EventRef theEvent, void* userData);
|
|
|
|
pascal OSStatus CEvtHandleApplicationAppleEvent (EventHandlerCallRef nextHandler, EventRef theEvent, void* userData);
|
|
|
|
pascal OSStatus CEvtHandleApplicationMouseMoved (EventHandlerCallRef nextHandler, EventRef theEvent, void* userData);
|
|
|
|
pascal OSStatus CEvtHandleApplicationMouseUp (EventHandlerCallRef nextHandler, EventRef theEvent, void* userData);
|
|
|
|
pascal OSStatus CEvtHandleApplicationMenuClick (EventHandlerCallRef nextHandler, EventRef theEvent, void* userData);
|
|
|
|
pascal OSStatus CEvtHandleApplicationMenus (EventHandlerCallRef nextHandler, EventRef theEvent, void* userData);
|
|
|
|
|
2001-09-26 04:31:41 +04:00
|
|
|
// Event handlers
|
2002-09-30 18:03:20 +04:00
|
|
|
OSStatus HandleKey(EventRef theEvent, Bit32u keyState);
|
2006-08-03 20:01:23 +04:00
|
|
|
static BxEvent * CarbonSiminterfaceCallback(void *theClass, BxEvent *event);
|
|
|
|
static bxevent_handler old_callback = NULL;
|
|
|
|
static void *old_callback_arg = NULL;
|
2002-09-30 18:03:20 +04:00
|
|
|
|
2001-09-26 04:31:41 +04:00
|
|
|
// Show/hide UI elements
|
|
|
|
void HidePointer(void);
|
|
|
|
void ShowPointer(void);
|
|
|
|
void HideTools(void);
|
|
|
|
void ShowTools(void);
|
|
|
|
void HideMenubar(void);
|
|
|
|
void ShowMenubar(void);
|
2002-03-09 05:40:25 +03:00
|
|
|
// void HideConsole(void);
|
|
|
|
// void ShowConsole(void);
|
2001-09-26 04:31:41 +04:00
|
|
|
|
2002-10-18 15:46:19 +04:00
|
|
|
void UpdateTools(void);
|
|
|
|
|
2001-09-26 04:31:41 +04:00
|
|
|
// Initialisation
|
|
|
|
void InitToolbox(void);
|
|
|
|
void CreateTile(void);
|
|
|
|
void CreateMenus(void);
|
|
|
|
void CreateWindows(void);
|
|
|
|
void CreateKeyMap(void);
|
2007-03-23 11:30:22 +03:00
|
|
|
void CreateVGAFont(unsigned char *vga_charmap);
|
2002-11-14 04:40:11 +03:00
|
|
|
BitMap *CreateBitMap(unsigned width, unsigned height);
|
2001-09-26 04:31:41 +04:00
|
|
|
PixMapHandle CreatePixMap(unsigned left, unsigned top, unsigned width,
|
2002-11-14 04:40:11 +03:00
|
|
|
unsigned height, unsigned depth, CTabHandle clut);
|
2001-09-26 04:31:41 +04:00
|
|
|
|
2002-03-09 05:40:25 +03:00
|
|
|
static pascal OSErr QuitAppleEventHandler(const AppleEvent *appleEvt, AppleEvent* reply, SInt32 refcon);
|
2001-09-26 04:32:34 +04:00
|
|
|
|
2002-10-25 01:07:56 +04:00
|
|
|
class bx_carbon_gui_c : public bx_gui_c {
|
|
|
|
public:
|
|
|
|
bx_carbon_gui_c (void) {}
|
|
|
|
DECLARE_GUI_VIRTUAL_METHODS()
|
2006-08-03 20:01:23 +04:00
|
|
|
virtual void beep_on(float frequency);
|
|
|
|
virtual void beep_off();
|
2002-10-25 01:07:56 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
// declare one instance of the gui object and call macro to insert the
|
|
|
|
// plugin code
|
|
|
|
static bx_carbon_gui_c *theGui = NULL;
|
|
|
|
IMPLEMENT_GUI_PLUGIN_CODE(carbon)
|
2001-09-26 04:32:34 +04:00
|
|
|
|
2002-10-25 01:07:56 +04:00
|
|
|
#define LOG_THIS theGui->
|
2001-09-26 04:32:34 +04:00
|
|
|
|
2002-03-09 05:40:25 +03:00
|
|
|
// Carbon Event Handlers
|
|
|
|
|
2002-10-18 15:46:19 +04:00
|
|
|
pascal OSStatus CEvtHandleWindowToolCommand (EventHandlerCallRef nextHandler,
|
2002-11-14 04:40:11 +03:00
|
|
|
EventRef theEvent,
|
|
|
|
void* userData)
|
2002-03-09 05:40:25 +03:00
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
HICommand commandStruct;
|
|
|
|
UInt32 theCommandID;
|
|
|
|
|
|
|
|
GetEventParameter (theEvent, kEventParamDirectObject,
|
2008-02-07 21:28:50 +03:00
|
|
|
typeHICommand, NULL, sizeof(HICommand),
|
2002-11-14 04:40:11 +03:00
|
|
|
NULL, &commandStruct);
|
|
|
|
|
|
|
|
theCommandID = commandStruct.commandID;
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2007-03-23 11:30:22 +03:00
|
|
|
if(theCommandID < toolPixMaps) {
|
2002-11-14 04:40:11 +03:00
|
|
|
bx_tool_pixmap[theCommandID].f();
|
|
|
|
}
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
return noErr; // Report success
|
2002-03-09 05:40:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
pascal OSStatus CEvtHandleWindowToolUpdate (EventHandlerCallRef nextHandler,
|
2002-11-14 04:40:11 +03:00
|
|
|
EventRef theEvent,
|
|
|
|
void* userData)
|
2002-03-09 05:40:25 +03:00
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
theGui->show_headerbar();
|
2002-03-09 05:40:25 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
return noErr; // Report success
|
2002-03-09 05:40:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
pascal OSStatus CEvtHandleWindowBackdropUpdate (EventHandlerCallRef nextHandler,
|
2002-11-14 04:40:11 +03:00
|
|
|
EventRef theEvent,
|
|
|
|
void* userData)
|
2002-03-09 05:40:25 +03:00
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
Rect box;
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
WindowRef myWindow;
|
|
|
|
GetEventParameter (theEvent, kEventParamDirectObject, typeWindowRef,
|
|
|
|
NULL, sizeof(WindowRef), NULL, &myWindow);
|
2002-03-09 05:40:25 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
GetWindowPortBounds(myWindow, &box);
|
|
|
|
BackColor(blackColor);
|
|
|
|
EraseRect(&box);
|
2002-03-09 05:40:25 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
return noErr; // Report success
|
2002-03-09 05:40:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Translate MouseDowns in a handled window into Bochs events
|
2017-01-15 14:44:43 +03:00
|
|
|
// Main ::handle_events() will feed all mouse updates to Bochs
|
2002-03-09 05:40:25 +03:00
|
|
|
pascal OSStatus CEvtHandleWindowEmulatorClick (EventHandlerCallRef nextHandler,
|
2002-11-14 04:40:11 +03:00
|
|
|
EventRef theEvent,
|
|
|
|
void* userData)
|
2002-03-09 05:40:25 +03:00
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
UInt32 keyModifiers;
|
|
|
|
GetEventParameter (theEvent, kEventParamKeyModifiers, typeUInt32,
|
|
|
|
NULL, sizeof(UInt32), NULL, &keyModifiers);
|
|
|
|
|
2007-03-23 11:30:22 +03:00
|
|
|
//if (!IsWindowActive(win))
|
|
|
|
//{
|
2002-11-14 04:40:11 +03:00
|
|
|
// SelectWindow(win);
|
2007-03-23 11:30:22 +03:00
|
|
|
//}
|
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
if (keyModifiers & cmdKey)
|
|
|
|
mouse_button_state |= 0x02;
|
|
|
|
else
|
|
|
|
mouse_button_state |= 0x01;
|
|
|
|
|
|
|
|
return noErr; // Report success
|
2002-03-09 05:40:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
pascal OSStatus CEvtHandleWindowEmulatorUpdate (EventHandlerCallRef nextHandler,
|
2002-11-14 04:40:11 +03:00
|
|
|
EventRef theEvent,
|
|
|
|
void* userData)
|
2002-03-09 05:40:25 +03:00
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
Rect box;
|
|
|
|
Pattern qdBlackPattern;
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
WindowRef myWindow;
|
|
|
|
GetEventParameter (theEvent, kEventParamDirectObject, typeWindowRef,
|
|
|
|
NULL, sizeof(WindowRef), NULL, &myWindow);
|
2002-03-09 05:40:25 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
GetWindowPortBounds(myWindow, &box);
|
|
|
|
DEV_vga_redraw_area(box.left, box.top, box.right, box.bottom);
|
2002-03-09 05:40:25 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
return noErr; // Report success
|
2002-03-09 05:40:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
pascal OSStatus CEvtHandleWindowEmulatorKeys (EventHandlerCallRef nextHandler,
|
2002-11-14 04:40:11 +03:00
|
|
|
EventRef theEvent,
|
|
|
|
void* userData)
|
2002-03-09 05:40:25 +03:00
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
UInt32 kind;
|
|
|
|
OSStatus outStatus = eventNotHandledErr;
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
kind = GetEventKind(theEvent);
|
|
|
|
switch(kind)
|
|
|
|
{
|
|
|
|
case kEventRawKeyDown:
|
|
|
|
case kEventRawKeyRepeat:
|
|
|
|
outStatus = HandleKey(theEvent, BX_KEY_PRESSED);
|
|
|
|
break;
|
|
|
|
case kEventRawKeyUp:
|
|
|
|
outStatus = HandleKey(theEvent, BX_KEY_RELEASED);
|
|
|
|
break;
|
2002-09-30 18:03:20 +04:00
|
|
|
}
|
2008-02-07 21:28:50 +03:00
|
|
|
|
|
|
|
return outStatus;
|
2002-03-09 05:40:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
// This stuff does work... it gets called, but converting the record
|
|
|
|
// and then calling AEProcessAppleEvent consistently results in noOutstandingHLE(err result -608)
|
|
|
|
// And its going to take more work to get RunApplicationLoop to work...
|
|
|
|
pascal OSStatus CEvtHandleApplicationAppleEvent (EventHandlerCallRef nextHandler,
|
2002-11-14 04:40:11 +03:00
|
|
|
EventRef theEvent,
|
|
|
|
void* userData)
|
2002-03-09 05:40:25 +03:00
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
EventRecord eventRec;
|
|
|
|
|
|
|
|
fprintf(stderr, "# Carbon apple event handler called\n");
|
|
|
|
if(ConvertEventRefToEventRecord(theEvent, &eventRec))
|
|
|
|
{
|
|
|
|
fprintf(stderr, "# Calling AEProcessAppleEvent\n");
|
|
|
|
OSStatus result = AEProcessAppleEvent(&eventRec);
|
|
|
|
fprintf(stderr, "# Received AE result: %i\n", result);
|
|
|
|
returm result;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
BX_PANIC(("Can't convert apple event"));
|
|
|
|
|
|
|
|
return noErr; // Report success
|
2002-03-09 05:40:25 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Only have our application deal with mouseEvents when we catch the movement
|
|
|
|
pascal OSStatus CEvtHandleApplicationMouseMoved (EventHandlerCallRef nextHandler,
|
2002-11-14 04:40:11 +03:00
|
|
|
EventRef theEvent,
|
|
|
|
void* userData)
|
2002-03-09 05:40:25 +03:00
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
mouseMoved = true;
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
return eventNotHandledErr;
|
2002-03-09 05:40:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
pascal OSStatus CEvtHandleApplicationMouseUp (EventHandlerCallRef nextHandler,
|
2002-11-14 04:40:11 +03:00
|
|
|
EventRef theEvent,
|
|
|
|
void* userData)
|
2002-03-09 05:40:25 +03:00
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
UInt32 keyModifiers;
|
|
|
|
GetEventParameter (theEvent, kEventParamKeyModifiers, typeUInt32,
|
|
|
|
NULL, sizeof(UInt32), NULL, &keyModifiers);
|
2002-03-09 05:40:25 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
if (keyModifiers & cmdKey)
|
|
|
|
mouse_button_state &= ~0x02;
|
|
|
|
else
|
|
|
|
mouse_button_state &= ~0x01;
|
2002-03-09 05:40:25 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
return eventNotHandledErr; // Don't want to eat all the mouseups
|
2002-03-09 05:40:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Catch MouseDown's in the menubar, trigger menu browsing
|
|
|
|
pascal OSStatus CEvtHandleApplicationMenuClick (EventHandlerCallRef nextHandler,
|
2002-11-14 04:40:11 +03:00
|
|
|
EventRef theEvent,
|
|
|
|
void* userData)
|
2002-03-09 05:40:25 +03:00
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
short part;
|
|
|
|
WindowPtr whichWindow;
|
2002-03-09 05:40:25 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
Point wheresMyMouse;
|
|
|
|
GetEventParameter (theEvent, kEventParamMouseLocation, typeQDPoint,
|
|
|
|
NULL, sizeof(Point), NULL, &wheresMyMouse);
|
2002-03-09 05:40:25 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
part = FindWindow(wheresMyMouse, &whichWindow);
|
2002-03-09 05:40:25 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
if(part == inMenuBar)
|
|
|
|
{
|
2008-02-07 21:28:50 +03:00
|
|
|
// MenuSelect will actually trigger an event cascade,
|
2002-11-14 04:40:11 +03:00
|
|
|
// Triggering command events for any selected menu item
|
|
|
|
MenuSelect(wheresMyMouse);
|
|
|
|
return noErr;
|
|
|
|
}
|
2002-03-09 05:40:25 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
return eventNotHandledErr; // Don't want to eat all the clicks
|
2002-03-09 05:40:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
pascal OSStatus CEvtHandleApplicationMenus (EventHandlerCallRef nextHandler,
|
2002-11-14 04:40:11 +03:00
|
|
|
EventRef theEvent,
|
|
|
|
void* userData)
|
2002-03-09 05:40:25 +03:00
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
HICommand commandStruct;
|
|
|
|
|
|
|
|
OSErr err = noErr;
|
|
|
|
short i;
|
|
|
|
|
|
|
|
GetEventParameter (theEvent, kEventParamDirectObject,
|
|
|
|
typeHICommand, NULL, sizeof(HICommand),
|
|
|
|
NULL, &commandStruct);
|
|
|
|
|
|
|
|
switch(commandStruct.commandID)
|
|
|
|
{
|
|
|
|
case kHICommandAbout:
|
|
|
|
{
|
|
|
|
DialogRef aboutDialog;
|
|
|
|
DialogItemIndex index;
|
|
|
|
CFStringRef cf_version;
|
|
|
|
char version[256];
|
2019-11-14 13:34:39 +03:00
|
|
|
sprintf(version, "Bochs x86 Emulator version %s (MacOS X port)", VERSION);
|
2002-11-14 04:40:11 +03:00
|
|
|
cf_version = CFStringCreateWithCString(NULL, version, kCFStringEncodingASCII);
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
AlertStdCFStringAlertParamRec aboutParam = {0};
|
|
|
|
aboutParam.version = kStdCFStringAlertVersionOne;
|
|
|
|
aboutParam.position = kWindowDefaultPosition;
|
|
|
|
aboutParam.defaultButton = kAlertStdAlertOKButton;
|
|
|
|
|
|
|
|
CreateStandardAlert(
|
|
|
|
kAlertNoteAlert,
|
|
|
|
cf_version,
|
|
|
|
NULL, /* can be NULL */
|
|
|
|
&aboutParam, /* can be NULL */
|
|
|
|
&aboutDialog);
|
|
|
|
|
|
|
|
RunStandardAlert(
|
|
|
|
aboutDialog,
|
|
|
|
NULL, /* can be NULL */
|
|
|
|
&index);
|
2008-02-16 01:05:43 +03:00
|
|
|
CFRelease(cf_version);
|
2002-11-14 04:40:11 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kHICommandQuit:
|
|
|
|
BX_EXIT(0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kCommandFloppy:
|
|
|
|
//DiskEject(1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kCommandCursor:
|
|
|
|
if (cursorVisible)
|
|
|
|
HidePointer();
|
|
|
|
else
|
|
|
|
ShowPointer();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kCommandTool:
|
|
|
|
if (IsWindowVisible(toolwin))
|
|
|
|
HideTools();
|
|
|
|
else
|
|
|
|
ShowTools();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kCommandMenuBar:
|
|
|
|
if (menubarVisible)
|
|
|
|
HideMenubar();
|
|
|
|
else
|
|
|
|
ShowMenubar();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kCommandFullScreen:
|
|
|
|
if (IsWindowVisible(toolwin) || menubarVisible)
|
|
|
|
{
|
|
|
|
if (menubarVisible)
|
|
|
|
HideMenubar();
|
|
|
|
if (IsWindowVisible(toolwin))
|
|
|
|
HideTools();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!menubarVisible)
|
|
|
|
ShowMenubar();
|
|
|
|
if (!IsWindowVisible(toolwin))
|
|
|
|
ShowTools();
|
|
|
|
}
|
|
|
|
break;
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-03-09 05:40:25 +03:00
|
|
|
/*
|
2002-11-14 04:40:11 +03:00
|
|
|
// Codewarrior programatic console that isn't available under Carbon without Codewarrior
|
|
|
|
case iConsole:
|
|
|
|
if (IsWindowVisible(SouixWin))
|
|
|
|
HideConsole();
|
|
|
|
else
|
|
|
|
ShowConsole();
|
|
|
|
break;
|
2002-03-09 05:40:25 +03:00
|
|
|
*/
|
2002-11-14 04:40:11 +03:00
|
|
|
case kCommandSnapshot:
|
|
|
|
bx_tool_pixmap[SNAPSHOT_TOOL_BUTTON].f();
|
|
|
|
break;
|
2002-10-18 15:46:19 +04:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
case kCommandReset:
|
|
|
|
bx_tool_pixmap[RESET_TOOL_BUTTON].f();
|
|
|
|
break;
|
2002-10-18 15:46:19 +04:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
case kHICommandCopy:
|
|
|
|
bx_tool_pixmap[COPY_TOOL_BUTTON].f();
|
|
|
|
break;
|
2002-10-18 15:46:19 +04:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
case kHICommandPaste:
|
|
|
|
bx_tool_pixmap[PASTE_TOOL_BUTTON].f();
|
|
|
|
break;
|
|
|
|
}
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
return noErr; // Report success
|
2002-03-09 05:40:25 +03:00
|
|
|
}
|
|
|
|
|
2001-09-26 04:31:41 +04:00
|
|
|
void MacPanic(void)
|
|
|
|
{
|
2001-09-26 04:32:34 +04:00
|
|
|
StopAlert(200, NULL);
|
2001-09-26 04:31:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void InitToolbox(void)
|
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
OSErr err;
|
2001-09-26 04:32:34 +04:00
|
|
|
// gQuitFlag = false;
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
InitCursor();
|
2001-09-26 04:32:34 +04:00
|
|
|
|
2002-03-09 05:40:25 +03:00
|
|
|
#if 0
|
2002-11-14 04:40:11 +03:00
|
|
|
// Our handler gets called... but I can't AEProcesAppleEvent successfully upon it?
|
|
|
|
EventTypeSpec appleEvent = { kEventClassAppleEvent, kEventAppleEvent };
|
|
|
|
InstallApplicationEventHandler(NewEventHandlerUPP(CEvtHandleApplicationAppleEvent),
|
|
|
|
1, &appleEvent, 0, NULL);
|
2002-03-09 05:40:25 +03:00
|
|
|
#endif
|
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
err = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication,
|
2002-11-14 04:40:11 +03:00
|
|
|
NewAEEventHandlerUPP(QuitAppleEventHandler), 0, false);
|
|
|
|
if (err != noErr)
|
|
|
|
ExitToShell();
|
2001-09-26 04:32:34 +04:00
|
|
|
}
|
|
|
|
|
2002-03-09 05:40:25 +03:00
|
|
|
static pascal OSErr QuitAppleEventHandler(const AppleEvent *appleEvt, AppleEvent* reply, SInt32 refcon)
|
2001-09-26 04:32:34 +04:00
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
//gQuitFlag = true;
|
|
|
|
BX_PANIC(("User terminated"));
|
|
|
|
return (noErr);
|
2001-09-26 04:31:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void CreateTile(void)
|
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
GDHandle saveDevice;
|
|
|
|
CGrafPtr savePort;
|
|
|
|
OSErr err;
|
2003-11-08 09:46:03 +03:00
|
|
|
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-07 21:28:50 +03:00
|
|
|
|
2006-02-22 00:35:09 +03:00
|
|
|
// if (SIM->get_param_bool(BXPN_PRIVATE_COLORMAP)->get())
|
2003-11-02 07:05:02 +03:00
|
|
|
// {
|
2002-11-14 04:40:11 +03:00
|
|
|
GetGWorld(&savePort, &saveDevice);
|
2012-10-14 22:29:44 +04:00
|
|
|
switch (disp_bpp) {
|
2003-11-08 09:46:03 +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-07 21:28:50 +03:00
|
|
|
|
2003-11-08 09:46:03 +03:00
|
|
|
BX_ASSERT((gMyBuffer = (Ptr)malloc(theRowBytes * (srcTileRect.bottom - srcTileRect.top))) != NULL);
|
2008-02-07 21:28:50 +03:00
|
|
|
err = NewGWorldFromPtr(&gOffWorld, p_f,
|
2012-10-14 22:29:44 +04:00
|
|
|
&srcTileRect, disp_bpp>8 ? NULL : gCTable, NULL, keepLocal, gMyBuffer, theRowBytes);
|
2003-11-02 07:05:02 +03:00
|
|
|
if (err != noErr || gOffWorld == NULL)
|
2003-11-08 09:46:03 +03:00
|
|
|
BX_PANIC(("mac: can't create gOffWorld; err=%hd", err));
|
2002-11-14 04:40:11 +03:00
|
|
|
|
|
|
|
SetGWorld(gOffWorld, NULL);
|
2003-11-08 09:46:03 +03:00
|
|
|
RGBForeColor(&black);
|
|
|
|
RGBBackColor(&white);
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
gTile = GetGWorldPixMap(gOffWorld);
|
2003-11-08 09:46:03 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
if (gTile != NULL)
|
|
|
|
{
|
|
|
|
NoPurgePixels(gTile);
|
2003-11-02 07:05:02 +03:00
|
|
|
if (!LockPixels(gTile))
|
|
|
|
BX_ERROR(("mac: can't LockPixels gTile"));
|
2003-11-08 09:46:03 +03:00
|
|
|
if ((**gTile).pixelType != RGBDirect && (**gTile).pmTable != gCTable)
|
2003-11-02 07:05:02 +03:00
|
|
|
{
|
|
|
|
DisposeCTable(gCTable);
|
|
|
|
gCTable = (**gTile).pmTable;
|
|
|
|
}
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2003-11-02 07:05:02 +03:00
|
|
|
(**gCTable).ctFlags |= 0x4000; //use palette manager indexes
|
|
|
|
CTabChanged(gCTable);
|
2002-11-14 04:40:11 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
BX_PANIC(("mac: can't create gTile"));
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
SetGWorld(savePort, saveDevice);
|
2003-11-02 07:05:02 +03:00
|
|
|
/* }
|
2002-11-14 04:40:11 +03:00
|
|
|
else
|
|
|
|
{
|
2003-11-02 07:05:02 +03:00
|
|
|
gOffWorld = NULL;
|
2002-11-14 04:40:11 +03:00
|
|
|
gTile = CreatePixMap(0, 0, srcTileRect.right, srcTileRect.bottom, 8, gCTable);
|
|
|
|
if (gTile == NULL)
|
|
|
|
BX_PANIC(("mac: can't create gTile"));
|
2003-11-02 07:05:02 +03:00
|
|
|
}*/
|
2001-09-26 04:31:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void CreateMenus(void)
|
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
Handle menu;
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
menu = GetNewMBar(rMBarID); // get our menus from resource
|
2008-02-07 21:28:50 +03:00
|
|
|
if (menu != nil)
|
2002-11-14 04:40:11 +03:00
|
|
|
{
|
|
|
|
SetMenuBar(menu);
|
|
|
|
DrawMenuBar();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
BX_PANIC(("can't create menu"));
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
SetMenuItemCommandID (GetMenuRef(mApple), iAbout, kHICommandAbout);
|
|
|
|
SetMenuItemCommandID (GetMenuRef(mFile), iQuit, kHICommandQuit);
|
|
|
|
SetMenuItemCommandID (GetMenuRef(mEdit), iCopy, kHICommandCopy);
|
|
|
|
SetMenuItemCommandID (GetMenuRef(mEdit), iPaste, kHICommandPaste);
|
|
|
|
SetMenuItemCommandID (GetMenuRef(mBochs), iFloppy, kCommandFloppy);
|
|
|
|
SetMenuItemCommandID (GetMenuRef(mBochs), iCursor, kCommandCursor);
|
|
|
|
SetMenuItemCommandID (GetMenuRef(mBochs), iTool, kCommandTool);
|
|
|
|
SetMenuItemCommandID (GetMenuRef(mBochs), iMenuBar, kCommandMenuBar);
|
|
|
|
SetMenuItemCommandID (GetMenuRef(mBochs), iFullScreen, kCommandFullScreen);
|
|
|
|
SetMenuItemCommandID (GetMenuRef(mBochs), iSnapshot, kCommandSnapshot);
|
|
|
|
SetMenuItemCommandID (GetMenuRef(mBochs), iReset, kCommandReset);
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
DisableMenuItem(GetMenuRef(mEdit), iUndo);
|
|
|
|
DisableMenuItem(GetMenuRef(mEdit), iCut);
|
|
|
|
DisableMenuItem(GetMenuRef(mEdit), iClear);
|
|
|
|
DisableMenuItem(GetMenuRef(mBochs), iFloppy);
|
|
|
|
|
|
|
|
EventTypeSpec commandEvents = {kEventClassCommand, kEventCommandProcess};
|
|
|
|
EventTypeSpec menuEvents = {kEventClassMouse, kEventMouseDown};
|
|
|
|
InstallApplicationEventHandler(NewEventHandlerUPP(CEvtHandleApplicationMenus),
|
|
|
|
1, &commandEvents, 0, NULL);
|
|
|
|
InstallApplicationEventHandler(NewEventHandlerUPP(CEvtHandleApplicationMenuClick),
|
|
|
|
1, &menuEvents, 0, NULL);
|
2001-09-26 04:32:34 +04:00
|
|
|
}
|
|
|
|
|
2001-09-26 04:31:41 +04:00
|
|
|
void CreateWindows(void)
|
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
Rect winRect;
|
|
|
|
Rect screenBounds;
|
|
|
|
Rect positioningBounds;
|
|
|
|
|
|
|
|
EventTypeSpec eventClick = { kEventClassWindow, kEventWindowHandleContentClick };
|
|
|
|
EventTypeSpec eventUpdate = { kEventClassWindow, kEventWindowDrawContent };
|
|
|
|
EventTypeSpec keyboardEvents[3] = {
|
|
|
|
{ kEventClassKeyboard, kEventRawKeyDown }, { kEventClassKeyboard, kEventRawKeyRepeat },
|
|
|
|
{ kEventClassKeyboard, kEventRawKeyUp }};
|
|
|
|
EventTypeSpec eventCommand = { kEventClassCommand, kEventCommandProcess };
|
|
|
|
|
|
|
|
// Create a backdrop window for fullscreen mode
|
|
|
|
// GetRegionBounds(GetGrayRgn(), &screenBounds);
|
|
|
|
|
|
|
|
// Fullscreen mode only really wants to be on one screen
|
|
|
|
screenBounds = (**GetMainDevice()).gdRect;
|
|
|
|
GetAvailableWindowPositioningBounds(GetMainDevice(), &positioningBounds);
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
SetRect(&winRect, 0, 0, screenBounds.right, screenBounds.bottom + GetMBarHeight());
|
2008-02-16 01:05:43 +03:00
|
|
|
CreateNewWindow(kPlainWindowClass, (kWindowStandardHandlerAttribute), &winRect, &backdrop);
|
2002-11-14 04:40:11 +03:00
|
|
|
if (backdrop == NULL)
|
|
|
|
{BX_PANIC(("mac: can't create backdrop window"));}
|
|
|
|
InstallWindowEventHandler(backdrop, NewEventHandlerUPP(CEvtHandleWindowBackdropUpdate), 1, &eventUpdate, NULL, NULL);
|
|
|
|
InstallWindowEventHandler(backdrop, NewEventHandlerUPP(CEvtHandleWindowEmulatorClick), 1, &eventClick, NULL, NULL);
|
|
|
|
InstallWindowEventHandler(backdrop, NewEventHandlerUPP(CEvtHandleWindowEmulatorKeys), 3, keyboardEvents, 0, NULL);
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
width = 640;
|
|
|
|
height = 480;
|
|
|
|
gLeft = positioningBounds.left;
|
|
|
|
gMinTop = positioningBounds.top;
|
|
|
|
gMaxTop = gMinTop + gheaderbar_y;
|
|
|
|
|
|
|
|
// Create a moveable tool window for the "headerbar"
|
|
|
|
winRect.top = positioningBounds.top + 10;
|
|
|
|
winRect.left = positioningBounds.left;
|
|
|
|
winRect.bottom = winRect.top + gheaderbar_y;
|
|
|
|
winRect.right = positioningBounds.right;
|
|
|
|
|
|
|
|
CreateNewWindow(kFloatingWindowClass, kWindowStandardHandlerAttribute, &winRect, &toolwin);
|
|
|
|
if (toolwin == NULL)
|
|
|
|
{BX_PANIC(("mac: can't create tool window"));}
|
|
|
|
|
|
|
|
// Use an Aqua-savvy window background
|
|
|
|
SetThemeWindowBackground(toolwin, kThemeBrushUtilityWindowBackgroundActive, false);
|
|
|
|
|
|
|
|
SetWindowTitleWithCFString (toolwin, CFSTR("MacBochs Hardware Controls")); // Set title
|
|
|
|
//InstallWindowEventHandler(toolwin, NewEventHandlerUPP(CEvtHandleWindowToolClick), 1, &eventClick, NULL, NULL);
|
|
|
|
InstallWindowEventHandler(toolwin, NewEventHandlerUPP(CEvtHandleWindowToolCommand), 1, &eventCommand, NULL, NULL);
|
|
|
|
InstallWindowEventHandler(toolwin, NewEventHandlerUPP(CEvtHandleWindowToolUpdate), 1, &eventUpdate, NULL, NULL);
|
|
|
|
|
|
|
|
// Create the emulator window for full screen mode
|
|
|
|
winRect.left = (screenBounds.right - width) /2; //(qd.screenBits.bounds.right - width)/2;
|
|
|
|
winRect.right = winRect.left + width;
|
|
|
|
winRect.top = (screenBounds.bottom - height)/2;
|
|
|
|
winRect.bottom = winRect.top + height;
|
|
|
|
|
|
|
|
CreateNewWindow(kPlainWindowClass, (kWindowStandardHandlerAttribute), &winRect, &fullwin);
|
|
|
|
if (fullwin == NULL)
|
|
|
|
BX_PANIC(("mac: can't create fullscreen emulator window"));
|
|
|
|
|
|
|
|
InstallWindowEventHandler(fullwin, NewEventHandlerUPP(CEvtHandleWindowEmulatorUpdate), 1, &eventUpdate, NULL, NULL);
|
|
|
|
InstallWindowEventHandler(fullwin, NewEventHandlerUPP(CEvtHandleWindowEmulatorClick), 1, &eventClick, NULL, NULL); InstallWindowEventHandler(fullwin, NewEventHandlerUPP(CEvtHandleWindowEmulatorKeys), 3, keyboardEvents, 0, NULL);
|
|
|
|
|
|
|
|
// Create the regular emulator window
|
|
|
|
winRect.left = gLeft;
|
|
|
|
winRect.top = gMaxTop;
|
|
|
|
winRect.right = winRect.left + width;
|
|
|
|
winRect.bottom = winRect.top + height;
|
|
|
|
|
|
|
|
CreateNewWindow(kDocumentWindowClass,
|
|
|
|
(kWindowStandardHandlerAttribute | kWindowCollapseBoxAttribute),
|
|
|
|
&winRect, &win);
|
|
|
|
if (win == NULL)
|
|
|
|
BX_PANIC(("mac: can't create emulator window"));
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
SetWindowTitleWithCFString (win, CFSTR("MacBochs x86 PC")); // Set title
|
|
|
|
InstallWindowEventHandler(win, NewEventHandlerUPP(CEvtHandleWindowEmulatorUpdate), 1, &eventUpdate, NULL, NULL);
|
|
|
|
InstallWindowEventHandler(win, NewEventHandlerUPP(CEvtHandleWindowEmulatorClick), 1, &eventClick, NULL, NULL);
|
|
|
|
InstallWindowEventHandler(win, NewEventHandlerUPP(CEvtHandleWindowEmulatorKeys), 3, keyboardEvents, 0, NULL);
|
|
|
|
|
|
|
|
// Group the fullscreen and backdrop windows together, since they also share the same click
|
|
|
|
// event handler they will effectively act as a single window for layering and events
|
|
|
|
|
|
|
|
CreateWindowGroup((kWindowGroupAttrLayerTogether | kWindowGroupAttrSharedActivation), &fullwinGroup);
|
|
|
|
SetWindowGroupName(fullwinGroup, CFSTR("net.sourceforge.bochs.windowgroups.fullscreen"));
|
|
|
|
|
|
|
|
// This *can't* be the right way, then again groups aren't yet the right way
|
|
|
|
// For the life of me I couldn't find a right way of making sure my created group stayed
|
|
|
|
// below the layer of Floating Windows. But with the windows we have there's no current
|
|
|
|
// harm from making it part of the same group.
|
|
|
|
SetWindowGroup(toolwin, fullwinGroup);
|
|
|
|
SetWindowGroup(fullwin, fullwinGroup);
|
|
|
|
SetWindowGroup(backdrop, fullwinGroup);
|
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
RepositionWindow(win, NULL, kWindowCenterOnMainScreen);
|
2002-11-14 04:40:11 +03:00
|
|
|
|
|
|
|
hidden = fullwin;
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
ShowWindow(toolwin);
|
|
|
|
ShowWindow(win);
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
SetPortWindowPort(win);
|
2001-09-26 04:31:41 +04:00
|
|
|
}
|
|
|
|
|
2017-01-15 14:44:43 +03:00
|
|
|
// CARBON implementation of the bx_gui_c methods (see nogui.cc for details)
|
2001-09-26 04:31:41 +04:00
|
|
|
|
2012-03-03 16:41:24 +04:00
|
|
|
void bx_carbon_gui_c::specific_init(int argc, char **argv, unsigned headerbar_y)
|
2007-03-23 11:30:22 +03:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2013-12-29 16:56:52 +04:00
|
|
|
put("CARBON");
|
2002-11-14 04:40:11 +03:00
|
|
|
InitToolbox();
|
2007-03-23 11:30:22 +03:00
|
|
|
|
|
|
|
font_width = 8;
|
|
|
|
font_height = 16;
|
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
gheaderbar_y = headerbar_y + TOOL_MARGIN_SPACE + TOOL_MARGIN_SPACE;
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
CreateKeyMap();
|
|
|
|
|
|
|
|
gCTable = GetCTable(128);
|
|
|
|
BX_ASSERT (gCTable != NULL);
|
2008-02-07 21:28:50 +03:00
|
|
|
CTabChanged(gCTable); //(*gCTable)->ctSeed = GetCTSeed();
|
2012-03-03 16:41:24 +04:00
|
|
|
SetRect(&srcTileRect, 0, 0, x_tilesize, y_tilesize);
|
2007-03-23 11:30:22 +03:00
|
|
|
|
|
|
|
for(i=0; i<256; i++) {
|
|
|
|
vgafont[i] = NULL;
|
|
|
|
}
|
2002-11-14 04:40:11 +03:00
|
|
|
CreateMenus();
|
2007-03-23 11:30:22 +03:00
|
|
|
CreateVGAFont(vga_charmap);
|
2002-11-14 04:40:11 +03:00
|
|
|
CreateTile();
|
|
|
|
CreateWindows();
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
EventTypeSpec mouseUpEvent = { kEventClassMouse, kEventMouseUp };
|
|
|
|
EventTypeSpec mouseMoved[2] = { { kEventClassMouse, kEventMouseMoved },
|
|
|
|
{ kEventClassMouse, kEventMouseDragged } };
|
|
|
|
InstallApplicationEventHandler(NewEventHandlerUPP(CEvtHandleApplicationMouseUp),
|
|
|
|
1, &mouseUpEvent, 0, NULL);
|
|
|
|
InstallApplicationEventHandler(NewEventHandlerUPP(CEvtHandleApplicationMouseMoved),
|
|
|
|
2, mouseMoved, 0, NULL);
|
|
|
|
|
2003-11-02 07:05:02 +03:00
|
|
|
if (GetCurrentProcess(&gProcessSerNum) == noErr)
|
|
|
|
SetFrontProcess(&gProcessSerNum);
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
GetMouse(&prevPt);
|
|
|
|
|
2006-08-03 20:01:23 +04:00
|
|
|
// redirect notify callback to X11 specific code
|
|
|
|
SIM->get_notify_callback(&old_callback, &old_callback_arg);
|
2002-11-14 04:40:11 +03:00
|
|
|
SIM->set_notify_callback(CarbonSiminterfaceCallback, NULL);
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
UNUSED(argc);
|
|
|
|
UNUSED(argv);
|
|
|
|
|
|
|
|
// loads keymap for x11
|
2006-02-22 22:18:29 +03:00
|
|
|
if (SIM->get_param_bool(BXPN_KBD_USEMAPPING)->get()) {
|
2002-11-14 04:40:11 +03:00
|
|
|
bx_keymap.loadKeymap(NULL); // I have no function to convert X windows symbols
|
|
|
|
}
|
2001-09-26 04:31:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// HandleKey()
|
|
|
|
//
|
|
|
|
// Handles keyboard-related events.
|
|
|
|
|
2002-09-30 18:03:20 +04:00
|
|
|
OSStatus HandleKey(EventRef theEvent, Bit32u keyState)
|
2001-09-26 04:31:41 +04:00
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
UInt32 key;
|
|
|
|
UInt32 trans;
|
2007-03-23 11:30:22 +03:00
|
|
|
OSStatus status;
|
2002-11-14 04:40:11 +03:00
|
|
|
UInt32 modifiers;
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
static UInt32 transState = 0;
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
status = GetEventParameter (theEvent,
|
|
|
|
kEventParamKeyModifiers,
|
|
|
|
typeUInt32, NULL,
|
|
|
|
sizeof(UInt32), NULL,
|
|
|
|
&modifiers);
|
2008-02-16 01:05:43 +03:00
|
|
|
if(status == noErr)
|
2002-11-14 04:40:11 +03:00
|
|
|
{
|
2002-09-30 18:03:20 +04:00
|
|
|
status = GetEventParameter (theEvent,
|
2002-11-14 04:40:11 +03:00
|
|
|
kEventParamKeyCode,
|
2002-09-30 18:03:20 +04:00
|
|
|
typeUInt32, NULL,
|
|
|
|
sizeof(UInt32), NULL,
|
2002-11-14 04:40:11 +03:00
|
|
|
&key);
|
2008-02-16 01:05:43 +03:00
|
|
|
if(status == noErr)
|
2002-09-30 18:03:20 +04:00
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
|
|
|
|
// key = event->message & charCodeMask;
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
// Let our menus process command keys
|
2008-02-16 01:05:43 +03:00
|
|
|
if(modifiers & cmdKey)
|
2002-11-14 04:40:11 +03:00
|
|
|
{
|
|
|
|
status = eventNotHandledErr;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-11-17 07:21:16 +03:00
|
|
|
/* if (modifiers & shiftKey)
|
2002-11-14 04:40:11 +03:00
|
|
|
DEV_kbd_gen_scancode(BX_KEY_SHIFT_L | keyState);
|
|
|
|
if (modifiers & controlKey)
|
|
|
|
DEV_kbd_gen_scancode(BX_KEY_CTRL_L | keyState);
|
|
|
|
if (modifiers & optionKey)
|
2003-11-17 07:21:16 +03:00
|
|
|
DEV_kbd_gen_scancode(BX_KEY_ALT_L | keyState);*/
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
// key = (event->message & keyCodeMask) >> 8;
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
trans = KeyTranslate(KCHR, key, &transState);
|
2003-11-17 07:21:16 +03:00
|
|
|
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;
|
2002-11-14 04:40:11 +03:00
|
|
|
// 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!
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
if (trans > 0)
|
|
|
|
DEV_kbd_gen_scancode(trans | keyState);
|
|
|
|
|
2003-11-17 07:21:16 +03:00
|
|
|
/* if (modifiers & shiftKey)
|
2002-11-14 04:40:11 +03:00
|
|
|
DEV_kbd_gen_scancode(BX_KEY_SHIFT_L | BX_KEY_RELEASED);
|
|
|
|
if (modifiers & controlKey)
|
|
|
|
DEV_kbd_gen_scancode(BX_KEY_CTRL_L | BX_KEY_RELEASED);
|
|
|
|
if (modifiers & optionKey)
|
2003-11-17 07:21:16 +03:00
|
|
|
DEV_kbd_gen_scancode(BX_KEY_ALT_L | BX_KEY_RELEASED);*/
|
2002-11-14 04:40:11 +03:00
|
|
|
}
|
2002-09-30 18:03:20 +04:00
|
|
|
}
|
2002-11-14 04:40:11 +03:00
|
|
|
}
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
return status;
|
2001-09-26 04:31:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
BX_CPP_INLINE void ResetPointer(void)
|
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
// this appears to work well, especially when combined with
|
|
|
|
// mouse processing on the MouseMoved events
|
|
|
|
if(CGWarpMouseCursorPosition(CGPointMake(scrCenter.h, scrCenter.v)))
|
|
|
|
{
|
|
|
|
fprintf(stderr, "# Failed to warp cursor");
|
|
|
|
}
|
2001-09-26 04:31:41 +04:00
|
|
|
}
|
|
|
|
|
2002-10-25 01:07:56 +04:00
|
|
|
void bx_carbon_gui_c::handle_events(void)
|
2001-09-26 04:31:41 +04:00
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
EventRecord event;
|
|
|
|
Point mousePt;
|
|
|
|
int dx, dy;
|
2003-11-17 07:21:16 +03:00
|
|
|
EventModifiers newMods;
|
2002-11-14 04:40:11 +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)
|
|
|
|
{
|
2002-03-09 05:40:25 +03:00
|
|
|
/*
|
2002-11-14 04:40:11 +03:00
|
|
|
// This event is just redundant
|
|
|
|
case nullEvent:
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
// These events are all covered by installed carbon event handlers
|
|
|
|
case mouseDown:
|
|
|
|
case mouseUp:
|
|
|
|
case keyDown:
|
|
|
|
case autoKey:
|
|
|
|
case keyUp:
|
|
|
|
case updateEvt:
|
|
|
|
break;
|
2008-02-07 21:28:50 +03:00
|
|
|
*/
|
2002-11-14 04:40:11 +03:00
|
|
|
case diskEvt:
|
|
|
|
// floppyA_handler();
|
|
|
|
break;
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
case kHighLevelEvent:
|
|
|
|
// fprintf(stderr, "# Classic apple event handler called\n");
|
|
|
|
AEProcessAppleEvent(&event);
|
|
|
|
show_headerbar(); // Update if necessary (example, clipboard change)
|
2003-11-17 07:21:16 +03:00
|
|
|
break;
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2003-11-17 07:21:16 +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-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
// Only update mouse if we're not in the dock
|
|
|
|
// and we are the frontmost app.
|
|
|
|
ProcessSerialNumber frontProcessSerNum;
|
|
|
|
Boolean isSameProcess;
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
GetFrontProcess(&frontProcessSerNum);
|
|
|
|
SameProcess(&frontProcessSerNum, &gProcessSerNum, &isSameProcess);
|
|
|
|
|
|
|
|
if(isSameProcess && !IsWindowCollapsed(win))
|
|
|
|
{
|
|
|
|
GetPort(&oldport);
|
|
|
|
SetPortWindowPort(win);
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
GetMouse(&mousePt);
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
if(menubarVisible && cursorVisible)
|
|
|
|
{
|
|
|
|
// Don't track the mouse if we're working with the main window
|
|
|
|
// and we're outside the window
|
|
|
|
if(mouseMoved &&
|
|
|
|
(mousePt.v < 0 || mousePt.v > height || mousePt.h < 0 || mousePt.h > width) &&
|
|
|
|
(prevPt.v < 0 || prevPt.v > height || prevPt.h < 0 || prevPt.h > width))
|
|
|
|
{
|
|
|
|
mouseMoved = false;
|
|
|
|
}
|
2002-03-09 05:40:25 +03:00
|
|
|
/*
|
2002-11-14 04:40:11 +03:00
|
|
|
// Limit mouse action to window
|
|
|
|
// Grr, any better ways to sync host and bochs cursor?
|
|
|
|
if(mousePt.h < 0) { mousePt.h = 0; }
|
|
|
|
else if(mousePt.h > width) { mousePt.h = width; }
|
|
|
|
if(mousePt.v < 0) { mousePt.v = 0; }
|
|
|
|
else if(mousePt.v > height) { mousePt.v = height; }
|
2002-03-09 05:40:25 +03:00
|
|
|
*/
|
2002-11-14 04:40:11 +03:00
|
|
|
}
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
//if mouse has moved, or button has changed state
|
|
|
|
if (mouseMoved || (curstate != mouse_button_state))
|
|
|
|
{
|
|
|
|
if(mouseMoved)
|
|
|
|
{
|
|
|
|
CGMouseDelta CGdX, CGdY;
|
2008-02-16 01:05:43 +03:00
|
|
|
CGGetLastMouseDelta(&CGdX, &CGdY);
|
2002-11-14 04:40:11 +03:00
|
|
|
dx = CGdX;
|
|
|
|
dy = - CGdY; // Windows has an opposing grid
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dx = 0;
|
|
|
|
dy = 0;
|
|
|
|
}
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2012-06-21 21:33:37 +04:00
|
|
|
DEV_mouse_motion(dx, dy, 0, mouse_button_state, 0);
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
if (!cursorVisible && mouseMoved)
|
|
|
|
{
|
|
|
|
SetPt(&scrCenter, 300, 240);
|
|
|
|
LocalToGlobal(&scrCenter);
|
|
|
|
ResetPointer(); //next getmouse should be 300, 240
|
|
|
|
SetPt(&mousePt, 300, 240);
|
|
|
|
}
|
|
|
|
mouseMoved = false;
|
2002-03-09 05:40:25 +03:00
|
|
|
}
|
2002-11-14 04:40:11 +03:00
|
|
|
|
|
|
|
prevPt = mousePt;
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
SetPort(oldport);
|
|
|
|
}
|
2001-09-26 04:31:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-10-25 01:07:56 +04:00
|
|
|
void bx_carbon_gui_c::flush(void)
|
2001-09-26 04:31:41 +04:00
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
// an opportunity to make the Window Manager happy.
|
|
|
|
// not needed on the macintosh....
|
2008-02-07 21:28:50 +03:00
|
|
|
|
|
|
|
// Unless you don't want to needlessly update the dock icon
|
2002-11-14 04:40:11 +03:00
|
|
|
// umpteen zillion times a second for each tile.
|
|
|
|
// A further note, UpdateCollapsedWindowDockTile is not
|
|
|
|
// recommended for animation. Setup like this my performance
|
|
|
|
// seems reasonable for little fuss.
|
|
|
|
if(windowUpdatesPending)
|
|
|
|
{
|
|
|
|
if(IsWindowCollapsed(win))
|
|
|
|
{
|
|
|
|
UpdateCollapsedWindowDockTile(win);
|
|
|
|
}
|
|
|
|
if(last_screen_state != screen_state)
|
|
|
|
{
|
|
|
|
last_screen_state = screen_state;
|
|
|
|
UpdateTools();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
windowUpdatesPending = false;
|
2001-09-26 04:31:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-10-25 01:07:56 +04:00
|
|
|
void bx_carbon_gui_c::clear_screen(void)
|
2001-09-26 04:31:41 +04:00
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
Rect r;
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
SetPortWindowPort(win);
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
RGBForeColor(&black);
|
|
|
|
RGBBackColor(&white);
|
|
|
|
GetWindowPortBounds(win, &r);
|
|
|
|
PaintRect (&r);
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
windowUpdatesPending = true;
|
2001-09-26 04:31:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-10-25 01:07:56 +04:00
|
|
|
void bx_carbon_gui_c::text_update(Bit8u *old_text, Bit8u *new_text,
|
2002-11-14 04:40:11 +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-09-26 04:31:41 +04:00
|
|
|
{
|
2008-02-03 13:04:02 +03:00
|
|
|
unsigned char cAttr, cChar;
|
2002-11-14 04:40:11 +03:00
|
|
|
Rect destRect;
|
|
|
|
RGBColor fgColor, bgColor;
|
2003-11-02 07:05:02 +03:00
|
|
|
GrafPtr oldPort, savePort;
|
|
|
|
GDHandle saveDevice;
|
2002-11-14 04:40:11 +03:00
|
|
|
GrafPtr winGrafPtr = GetWindowPort(win);
|
2003-11-02 07:05:02 +03:00
|
|
|
OSErr theError;
|
2008-02-03 13:04:02 +03:00
|
|
|
Bit8u *old_line, *new_line;
|
2012-01-22 16:22:03 +04:00
|
|
|
unsigned int curs, hchars, offset, rows, x, xc, y, yc, i;
|
2021-01-30 21:32:52 +03:00
|
|
|
bool forceUpdate = 0, blink_mode, blink_state;
|
2008-02-03 13:04:02 +03:00
|
|
|
static unsigned prev_cursor_x=0;
|
|
|
|
static unsigned prev_cursor_y=0;
|
2012-01-22 16:22:03 +04:00
|
|
|
char text_palette[16];
|
2008-02-03 13:04:02 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
screen_state = TEXT_MODE;
|
2007-03-23 11:30:22 +03:00
|
|
|
|
2008-02-03 13:04:02 +03:00
|
|
|
// first check if the screen needs to be redrawn completely
|
2012-01-22 16:22:03 +04:00
|
|
|
blink_mode = (tm_info->blink_flags & BX_TEXT_BLINK_MODE) > 0;
|
|
|
|
blink_state = (tm_info->blink_flags & BX_TEXT_BLINK_STATE) > 0;
|
2008-02-03 13:04:02 +03:00
|
|
|
if (blink_mode) {
|
2012-01-22 16:22:03 +04:00
|
|
|
if (tm_info->blink_flags & BX_TEXT_BLINK_TOGGLE)
|
2008-02-03 13:04:02 +03:00
|
|
|
forceUpdate = 1;
|
|
|
|
}
|
|
|
|
if (charmap_updated == 1) {
|
2007-03-23 11:30:22 +03:00
|
|
|
CreateVGAFont(vga_charmap);
|
|
|
|
charmap_updated = 0;
|
2008-02-03 13:04:02 +03:00
|
|
|
forceUpdate = 1;
|
2007-03-23 11:30:22 +03:00
|
|
|
}
|
|
|
|
|
2012-01-22 16:22:03 +04:00
|
|
|
for (i = 0; i < 16; i++) {
|
|
|
|
text_palette[i] = tm_info->actl_palette[i];
|
|
|
|
}
|
|
|
|
|
2008-02-03 13:04:02 +03:00
|
|
|
// invalidate character at previous and new cursor location
|
|
|
|
if((prev_cursor_y < text_rows) && (prev_cursor_x < text_cols)) {
|
2012-01-22 16:22:03 +04:00
|
|
|
curs = prev_cursor_y * tm_info->line_offset + prev_cursor_x * 2;
|
2008-02-03 13:04:02 +03:00
|
|
|
old_text[curs] = ~new_text[curs];
|
|
|
|
}
|
2012-01-22 16:22:03 +04:00
|
|
|
if((tm_info->cs_start <= tm_info->cs_end) && (tm_info->cs_start < font_height) &&
|
2008-02-03 13:04:02 +03:00
|
|
|
(cursor_y < text_rows) && (cursor_x < text_cols)) {
|
2012-01-22 16:22:03 +04:00
|
|
|
curs = cursor_y * tm_info->line_offset + cursor_x * 2;
|
2008-02-03 13:04:02 +03:00
|
|
|
old_text[curs] = ~new_text[curs];
|
|
|
|
} else {
|
|
|
|
curs = 0xffff;
|
|
|
|
}
|
2002-11-14 04:40:11 +03:00
|
|
|
|
2008-02-03 13:04:02 +03:00
|
|
|
GetPort(&oldPort);
|
2007-03-23 11:30:22 +03:00
|
|
|
|
2008-02-03 13:04:02 +03:00
|
|
|
SetPortWindowPort(win);
|
2002-11-14 04:40:11 +03:00
|
|
|
|
2008-02-03 13:04:02 +03:00
|
|
|
rows = text_rows;
|
|
|
|
y = 0;
|
|
|
|
do {
|
|
|
|
hchars = text_cols;
|
|
|
|
new_line = new_text;
|
|
|
|
old_line = old_text;
|
|
|
|
x = 0;
|
2012-01-22 16:22:03 +04:00
|
|
|
offset = y * tm_info->line_offset;
|
2008-02-03 13:04:02 +03:00
|
|
|
do {
|
|
|
|
if (forceUpdate || (old_text[0] != new_text[0])
|
|
|
|
|| (old_text[1] != new_text[1])) {
|
|
|
|
cChar = new_text[0];
|
|
|
|
cAttr = new_text[1];
|
|
|
|
|
|
|
|
if (blink_mode) {
|
|
|
|
cAttr = new_text[1] & 0x7F;
|
|
|
|
if (!blink_state && (new_text[1] & 0x80))
|
|
|
|
cAttr = (cAttr & 0x70) | (cAttr >> 4);
|
|
|
|
}
|
|
|
|
if (offset == curs) {
|
|
|
|
cAttr = (cAttr >> 4) | (cAttr << 4);
|
2012-01-22 16:22:03 +04:00
|
|
|
}
|
2008-02-03 13:04:02 +03:00
|
|
|
|
|
|
|
if (SIM->get_param_bool(BXPN_PRIVATE_COLORMAP)->get()) {
|
2012-01-22 16:22:03 +04:00
|
|
|
PmForeColor(text_palette[cAttr & 0x0F]);
|
2008-02-03 13:04:02 +03:00
|
|
|
if (blink_mode) {
|
2012-01-22 16:22:03 +04:00
|
|
|
PmBackColor(text_palette[(cAttr & 0x70) >> 4]);
|
|
|
|
if (!blink_state && (cAttr & 0x80))
|
|
|
|
PmForeColor(text_palette[(cAttr & 0x70) >> 4]);
|
2008-02-03 13:04:02 +03:00
|
|
|
} else {
|
2012-01-22 16:22:03 +04:00
|
|
|
PmBackColor(text_palette[(cAttr & 0xF0) >> 4]);
|
2008-02-03 13:04:02 +03:00
|
|
|
}
|
|
|
|
} else {
|
2012-01-22 16:22:03 +04:00
|
|
|
fgColor = (**gCTable).ctTable[text_palette[cAttr & 0x0F]].rgb;
|
|
|
|
bgColor = (**gCTable).ctTable[text_palette[(cAttr & 0xF0) >> 4]].rgb;
|
2008-02-03 13:04:02 +03:00
|
|
|
|
|
|
|
RGBForeColor(&fgColor);
|
|
|
|
RGBBackColor(&bgColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
xc = x * font_width;
|
|
|
|
yc = y * font_height;
|
|
|
|
|
|
|
|
SetRect(&destRect, xc, yc,
|
|
|
|
xc+font_width, yc+font_height);
|
|
|
|
|
|
|
|
CopyBits(vgafont[cChar], WINBITMAP(win),
|
|
|
|
&srcTextRect, &destRect, srcCopy, NULL);
|
|
|
|
|
|
|
|
if ((theError = QDError()) != noErr)
|
|
|
|
BX_ERROR(("mac: CopyBits returned %hd", theError));
|
2002-11-14 04:40:11 +03:00
|
|
|
}
|
2008-02-03 13:04:02 +03:00
|
|
|
x++;
|
|
|
|
new_text+=2;
|
|
|
|
old_text+=2;
|
|
|
|
offset+=2;
|
|
|
|
} while (--hchars);
|
|
|
|
y++;
|
2012-01-22 16:22:03 +04:00
|
|
|
new_text = new_line + tm_info->line_offset;
|
|
|
|
old_text = old_line + tm_info->line_offset;
|
2008-02-03 13:04:02 +03:00
|
|
|
} while (--rows);
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2008-02-03 13:04:02 +03:00
|
|
|
//previous cursor position
|
|
|
|
prev_cursor_x = cursor_x;
|
|
|
|
prev_cursor_y = cursor_y;
|
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
SetPort(oldPort);
|
2008-02-03 13:04:02 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
windowUpdatesPending = true;
|
2001-09-26 04:31:41 +04:00
|
|
|
}
|
|
|
|
|
2007-03-23 11:30:22 +03:00
|
|
|
int bx_carbon_gui_c::get_clipboard_text(Bit8u **bytes, Bit32s *nbytes)
|
2002-03-16 14:30:06 +03:00
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
ScrapRef theScrap;
|
|
|
|
ScrapFlavorFlags theScrapFlags;
|
|
|
|
Size theScrapSize;
|
|
|
|
OSStatus err;
|
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
GetCurrentScrap(&theScrap);
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
// Make sure there is text to paste
|
2008-02-16 01:05:43 +03:00
|
|
|
err= GetScrapFlavorFlags(theScrap, kScrapFlavorTypeText, &theScrapFlags);
|
2002-11-14 04:40:11 +03:00
|
|
|
if(err == noErr)
|
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
GetScrapFlavorSize(theScrap, kScrapFlavorTypeText, &theScrapSize);
|
2002-11-14 04:40:11 +03:00
|
|
|
*nbytes = theScrapSize;
|
|
|
|
*bytes = new Bit8u[1 + *nbytes];
|
|
|
|
BX_INFO (("found %d bytes on the clipboard", *nbytes));
|
2008-02-16 01:05:43 +03:00
|
|
|
err= GetScrapFlavorData(theScrap, kScrapFlavorTypeText, &theScrapSize, *bytes);
|
2002-11-14 04:40:11 +03:00
|
|
|
BX_INFO (("first byte is 0x%02x", *bytes[0]));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
BX_INFO (("No text found on clipboard..."));
|
|
|
|
}
|
|
|
|
return (err == noErr);
|
2002-03-16 14:30:06 +03:00
|
|
|
}
|
|
|
|
|
2007-03-23 11:30:22 +03:00
|
|
|
int bx_carbon_gui_c::set_clipboard_text(char *text_snapshot, Bit32u len)
|
2002-03-15 19:45:10 +03:00
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
ScrapRef theScrap;
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
// Clear out the existing clipboard
|
2008-02-16 01:05:43 +03:00
|
|
|
ClearCurrentScrap();
|
|
|
|
|
|
|
|
GetCurrentScrap(&theScrap);
|
|
|
|
PutScrapFlavor (theScrap, kScrapFlavorTypeText, kScrapFlavorMaskNone, len, text_snapshot);
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
return 1;
|
2002-03-15 19:45:10 +03:00
|
|
|
}
|
|
|
|
|
2021-01-30 21:32:52 +03:00
|
|
|
bool bx_carbon_gui_c::palette_change(Bit8u index, Bit8u red, Bit8u green, Bit8u blue)
|
2001-09-26 04:31:41 +04:00
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
PaletteHandle thePal, oldpal;
|
|
|
|
GDHandle saveDevice;
|
|
|
|
CGrafPtr savePort;
|
2003-11-02 07:05:02 +03:00
|
|
|
GrafPtr oldPort;
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2006-02-22 00:35:09 +03:00
|
|
|
/* if (gOffWorld != NULL) //(SIM->get_param_bool(BXPN_PRIVATE_COLORMAP)->get())
|
2002-11-14 04:40:11 +03:00
|
|
|
{
|
|
|
|
GetGWorld(&savePort, &saveDevice);
|
|
|
|
|
|
|
|
SetGWorld(gOffWorld, NULL);
|
2003-11-02 07:05:02 +03:00
|
|
|
}*/
|
2003-11-08 09:46:03 +03:00
|
|
|
if ((**gTile).pixelType != RGBDirect)
|
|
|
|
{
|
|
|
|
GetPort(&oldPort);
|
|
|
|
SetPortWindowPort(win);
|
2002-11-14 04:40:11 +03:00
|
|
|
|
2003-11-08 09:46:03 +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);
|
2002-11-14 04:40:11 +03:00
|
|
|
|
2003-11-08 09:46:03 +03:00
|
|
|
SetEntries(index, index, (**gCTable).ctTable);
|
|
|
|
|
|
|
|
CTabChanged(gCTable);
|
|
|
|
|
|
|
|
SetPort(oldPort);
|
|
|
|
}
|
2006-02-22 00:35:09 +03:00
|
|
|
/* if (gOffWorld != NULL) //(SIM->get_param_bool(BXPN_PRIVATE_COLORMAP)->get())
|
2003-11-02 07:05:02 +03:00
|
|
|
SetGWorld(savePort, saveDevice);*/
|
2006-02-22 00:35:09 +03:00
|
|
|
if (SIM->get_param_bool(BXPN_PRIVATE_COLORMAP)->get())
|
2002-11-14 04:40:11 +03:00
|
|
|
{
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
thePal = NewPalette(index, gCTable, pmTolerant, 0x5000);
|
|
|
|
oldpal = GetPalette(win);
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
SetPalette(win, thePal, false);
|
|
|
|
SetPalette(fullwin, thePal, false);
|
|
|
|
SetPalette(hidden, thePal, false);
|
2003-11-08 09:46:03 +03:00
|
|
|
return(1);
|
2002-11-14 04:40:11 +03:00
|
|
|
}
|
|
|
|
|
2003-11-08 09:46:03 +03:00
|
|
|
return((**gTile).pixelType != RGBDirect);
|
2001-09-26 04:31:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-10-25 01:07:56 +04:00
|
|
|
void bx_carbon_gui_c::graphics_tile_update(Bit8u *tile, unsigned x0, unsigned y0)
|
2001-09-26 04:31:41 +04:00
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
Rect destRect;
|
2003-11-02 07:05:02 +03:00
|
|
|
OSErr theError;
|
|
|
|
Ptr theBaseAddr;
|
|
|
|
GDHandle saveDevice;
|
2002-11-14 04:40:11 +03:00
|
|
|
CGrafPtr savePort;
|
2003-11-02 07:05:02 +03:00
|
|
|
GrafPtr oldPort;
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2003-11-02 07:05:02 +03:00
|
|
|
/* if (gOffWorld != NULL)
|
|
|
|
{
|
|
|
|
GetGWorld(&savePort, &saveDevice);
|
|
|
|
|
|
|
|
SetGWorld(gOffWorld, NULL);
|
|
|
|
}*/
|
2001-09-26 04:31:41 +04:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
screen_state = GRAPHIC_MODE;
|
|
|
|
|
|
|
|
// SetPort - Otherwise an update happens to the headerbar and ooomph, we're drawing weirdly on the screen
|
2003-11-02 07:05:02 +03:00
|
|
|
GetPort(&oldPort);
|
2002-11-14 04:40:11 +03:00
|
|
|
SetPortWindowPort(win);
|
|
|
|
destRect = srcTileRect;
|
|
|
|
OffsetRect(&destRect, x0, y0);
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2003-11-02 07:05:02 +03:00
|
|
|
//(**gTile).baseAddr = (Ptr)tile;
|
2003-11-08 09:46:03 +03:00
|
|
|
if ((theError = LockPortBits(gOffWorld)) != noErr)
|
|
|
|
BX_PANIC(("mac: LockPortBits returned %hd", theError));
|
2003-11-02 07:05:02 +03:00
|
|
|
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++) {
|
2003-11-08 09:46:03 +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];
|
2003-11-08 09:46:03 +03:00
|
|
|
}
|
|
|
|
}
|
2012-10-14 22:29:44 +04:00
|
|
|
} else {
|
2003-11-08 09:46:03 +03:00
|
|
|
BlockMoveData(tile, theBaseAddr, (srcTileRect.bottom-srcTileRect.top) * GetPixRowBytes(gTile));
|
2012-10-14 22:29:44 +04:00
|
|
|
}
|
2003-11-08 09:46:03 +03:00
|
|
|
if ((theError = UnlockPortBits(gOffWorld)) != noErr)
|
|
|
|
BX_ERROR(("mac: UnlockPortBits returned %hd", theError));
|
|
|
|
RGBForeColor(&black);
|
|
|
|
RGBBackColor(&white);
|
2008-02-16 01:05:43 +03:00
|
|
|
CopyBits(GetPortBitMapForCopyBits(gOffWorld), WINBITMAP(win),
|
2002-11-14 04:40:11 +03:00
|
|
|
&srcTileRect, &destRect, srcCopy, NULL);
|
2003-11-02 07:05:02 +03:00
|
|
|
if ((theError = QDError()) != noErr)
|
|
|
|
BX_ERROR(("mac: CopyBits returned %hd", theError));
|
|
|
|
SetPort(oldPort);
|
2002-11-14 04:40:11 +03:00
|
|
|
windowUpdatesPending = true;
|
2003-11-02 07:05:02 +03:00
|
|
|
/* if (gOffWorld != NULL)
|
|
|
|
SetGWorld(savePort, saveDevice);*/
|
2001-09-26 04:31:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-06-28 12:04:31 +04:00
|
|
|
void bx_carbon_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight, unsigned fwidth, unsigned bpp)
|
2001-09-26 04:31:41 +04:00
|
|
|
{
|
2003-11-08 09:46:03 +03:00
|
|
|
if ((bpp != 1) && (bpp != 2) && (bpp != 4) && (bpp != 8) && (bpp != 15) && (bpp != 16) && (bpp != 24) && (bpp != 32)) {
|
2003-06-28 12:04:31 +04:00
|
|
|
BX_PANIC(("%d bpp graphics mode not supported yet", bpp));
|
|
|
|
}
|
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) {
|
2003-11-08 09:46:03 +03:00
|
|
|
free(gMyBuffer);
|
|
|
|
DisposeGWorld(gOffWorld);
|
|
|
|
if ((gCTable == NULL) || (*gCTable == NULL) || (*gCTable == (void *)-1))
|
|
|
|
gCTable = GetCTable(128);
|
2012-10-14 22:29:44 +04:00
|
|
|
disp_bpp = bpp;
|
2003-11-08 09:46:03 +03:00
|
|
|
CreateTile();
|
|
|
|
}
|
2007-03-23 11:30:22 +03:00
|
|
|
|
2012-10-14 22:29:44 +04:00
|
|
|
if (guest_textmode) {
|
2008-01-26 03:00:31 +03:00
|
|
|
text_cols = x / fwidth;
|
|
|
|
text_rows = y / fheight;
|
2008-02-16 01:05:43 +03:00
|
|
|
if(fwidth != font_width || fheight != font_height) {
|
2007-03-23 11:30:22 +03:00
|
|
|
font_width = fwidth;
|
|
|
|
font_height = fheight;
|
|
|
|
CreateVGAFont(vga_charmap);
|
2002-04-20 11:19:35 +04:00
|
|
|
}
|
|
|
|
}
|
2007-03-23 11:30:22 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
if (x != width || y != height)
|
|
|
|
{
|
2002-03-09 05:40:25 +03:00
|
|
|
#if 1
|
2002-11-14 04:40:11 +03:00
|
|
|
SizeWindow(win, x, y, false);
|
2002-03-09 05:40:25 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if 0
|
2002-11-14 04:40:11 +03:00
|
|
|
// Animates the resizing, cute, but gratuitous
|
|
|
|
Rect box, frame;
|
|
|
|
GetWindowBounds(win, kWindowStructureRgn, &frame);
|
|
|
|
GetWindowPortBounds(win, &box);
|
|
|
|
frame.right = frame.right - box.right + x;
|
|
|
|
frame.bottom = frame.bottom - box.bottom + y;
|
|
|
|
|
|
|
|
TransitionWindow(win, kWindowSlideTransitionEffect, kWindowResizeTransitionAction, &frame);
|
2002-03-09 05:40:25 +03:00
|
|
|
#endif
|
2002-11-14 04:40:11 +03:00
|
|
|
SizeWindow(fullwin, x, y, false);
|
|
|
|
SizeWindow(hidden, x, y, false);
|
|
|
|
width = x;
|
|
|
|
height = y;
|
|
|
|
}
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
windowUpdatesPending = true;
|
2004-08-15 23:27:15 +04:00
|
|
|
|
|
|
|
host_xres = x;
|
|
|
|
host_yres = y;
|
|
|
|
host_bpp = bpp;
|
2001-09-26 04:31:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ::CREATE_BITMAP()
|
|
|
|
//
|
|
|
|
// rewritten by tim senecal to use the cicn (color icon) resources instead
|
|
|
|
|
2002-10-18 15:46:19 +04:00
|
|
|
// We need to have a cicn resource for each and every call to create_bitmap
|
|
|
|
// If this fails, it is probably because more icons were added to bochs and
|
2002-10-25 01:07:56 +04:00
|
|
|
// we need to create more cicns in bochs.r to match with create_bitmap calls in
|
|
|
|
// gui.cc
|
|
|
|
unsigned bx_carbon_gui_c::create_bitmap(const unsigned char *bmap, unsigned xdim, unsigned ydim)
|
2001-09-26 04:31:41 +04:00
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
unsigned i;
|
|
|
|
unsigned char *data;
|
|
|
|
long row_bytes, bytecount;
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
bx_cicn[numPixMaps] = GetCIcon(numPixMaps+128);
|
2007-03-23 11:30:22 +03:00
|
|
|
// BX_ASSERT(bx_cicn[numPixMaps]);
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
numPixMaps++;
|
|
|
|
|
|
|
|
return(numPixMaps-1);
|
2001-09-26 04:31:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-10-25 01:07:56 +04:00
|
|
|
unsigned bx_carbon_gui_c::headerbar_bitmap(unsigned bmap_id, unsigned alignment, void (*f)(void))
|
2001-09-26 04:31:41 +04:00
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
unsigned hb_index;
|
|
|
|
Rect destRect, r;
|
|
|
|
GetWindowPortBounds(toolwin, &r);
|
|
|
|
int xorigin, yorigin = TOOL_MARGIN_SPACE;
|
|
|
|
ControlButtonContentInfo info;
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
toolPixMaps++;
|
|
|
|
hb_index = toolPixMaps-1;
|
2007-03-23 11:30:22 +03:00
|
|
|
//bx_tool_pixmap[hb_index].pm = bx_pixmap[bmap_id];
|
|
|
|
//bx_tool_pixmap[hb_index].cicn = bx_cicn[bmap_id];
|
2002-11-14 04:40:11 +03:00
|
|
|
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 = TOOL_MARGIN_SPACE;
|
2007-03-23 11:30:22 +03:00
|
|
|
// bx_bitmap_left_xorigin += (**bx_pixmap[bmap_id]).bounds.right;
|
2002-11-14 04:40:11 +03:00
|
|
|
bx_bitmap_left_xorigin += 32 + TOOL_SPACING;
|
|
|
|
xorigin = bx_tool_pixmap[hb_index].xorigin;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-03-23 11:30:22 +03:00
|
|
|
// bx_bitmap_right_xorigin += (**bx_pixmap[bmap_id]).bounds.right;
|
2002-11-14 04:40:11 +03:00
|
|
|
bx_bitmap_right_xorigin += 32;
|
|
|
|
bx_tool_pixmap[hb_index].xorigin = bx_bitmap_right_xorigin;
|
|
|
|
bx_tool_pixmap[hb_index].yorigin = TOOL_MARGIN_SPACE;
|
|
|
|
xorigin = r.right - bx_tool_pixmap[hb_index].xorigin;
|
|
|
|
bx_bitmap_right_xorigin += TOOL_SPACING;
|
|
|
|
}
|
|
|
|
|
|
|
|
SetRect(&destRect, xorigin, yorigin, xorigin+32, yorigin+32);
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
info.contentType = kControlContentCIconHandle;
|
|
|
|
info.u.cIconHandle = bx_cicn[bmap_id];
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
CreateIconControl(toolwin, &destRect, &info, false, &(bx_tool_pixmap[hb_index].control));
|
2002-11-14 04:40:11 +03:00
|
|
|
SetControlCommandID(bx_tool_pixmap[hb_index].control, hb_index);
|
|
|
|
return(hb_index);
|
2001-09-26 04:31:41 +04:00
|
|
|
}
|
|
|
|
|
2002-10-25 01:07:56 +04:00
|
|
|
void bx_carbon_gui_c::show_headerbar(void)
|
2001-09-26 04:31:41 +04:00
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
UpdateTools();
|
|
|
|
DrawControls(toolwin);
|
2001-09-26 04:31:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-10-25 01:07:56 +04:00
|
|
|
void bx_carbon_gui_c::replace_bitmap(unsigned hbar_id, unsigned bmap_id)
|
2001-09-26 04:31:41 +04:00
|
|
|
{
|
2007-03-23 11:30:22 +03:00
|
|
|
//bx_tool_pixmap[hbar_id].pm = bx_pixmap[bmap_id];
|
|
|
|
//bx_tool_pixmap[hbar_id].cicn = bx_cicn[bmap_id];
|
2002-11-14 04:40:11 +03:00
|
|
|
ControlButtonContentInfo info;
|
2002-10-18 15:46:19 +04:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
info.contentType = kControlContentCIconHandle;
|
|
|
|
info.u.cIconHandle = bx_cicn[bmap_id];
|
2002-10-18 15:46:19 +04:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
SetControlData(bx_tool_pixmap[hbar_id].control,
|
|
|
|
kControlEntireControl, kControlIconContentTag, sizeof(ControlButtonContentInfo), &info);
|
|
|
|
show_headerbar();
|
2001-09-26 04:31:41 +04:00
|
|
|
}
|
|
|
|
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-10-25 01:07:56 +04:00
|
|
|
void bx_carbon_gui_c::exit(void)
|
2001-09-26 04:31:41 +04:00
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
if (!menubarVisible)
|
|
|
|
ShowMenubar(); // Make the menubar visible again
|
|
|
|
InitCursor();
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
// Make the clipboard all happy before we go
|
|
|
|
CallInScrapPromises();
|
2001-09-26 04:31:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
2002-10-25 01:07:56 +04:00
|
|
|
void bx_carbon_gui_c::snapshot_handler(void)
|
2001-09-26 04:31:41 +04:00
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
PicHandle ScreenShot;
|
|
|
|
long val;
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
SetPortWindowPort(win);
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
ScreenShot = OpenPicture(&win->portRect);
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
CopyBits(&win->portBits, &win->portBits, &win->portRect, &win->portRect, srcCopy, NULL);
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
ClosePicture();
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
val = ZeroScrap();
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
HLock((Handle)ScreenShot);
|
|
|
|
PutScrap(GetHandleSize((Handle)ScreenShot), 'PICT', *ScreenShot);
|
|
|
|
HUnlock((Handle)ScreenShot);
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
KillPicture(ScreenShot);
|
2001-09-26 04:31:41 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// HidePointer()
|
|
|
|
//
|
|
|
|
// Hides the Mac mouse pointer
|
|
|
|
|
|
|
|
void HidePointer()
|
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
HiliteMenu(0);
|
|
|
|
HideCursor();
|
|
|
|
SetPortWindowPort(win);
|
|
|
|
SetPt(&scrCenter, 300, 240);
|
|
|
|
LocalToGlobal(&scrCenter);
|
|
|
|
ResetPointer();
|
|
|
|
GetMouse(&prevPt);
|
|
|
|
cursorVisible = false;
|
2008-02-07 21:28:50 +03:00
|
|
|
CheckMenuItem(GetMenuHandle(mBochs), iCursor, false);
|
2001-09-26 04:31:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// ShowPointer()
|
|
|
|
//
|
|
|
|
// Shows the Mac mouse pointer
|
|
|
|
|
|
|
|
void ShowPointer()
|
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
InitCursor();
|
|
|
|
cursorVisible = true;
|
|
|
|
CheckMenuItem(GetMenuHandle(mBochs), iCursor, true);
|
|
|
|
//CheckItem(GetMenuHandle(mBochs), iCursor, true);
|
2001-09-26 04:31:41 +04:00
|
|
|
}
|
|
|
|
|
2002-10-18 15:46:19 +04:00
|
|
|
// UpdateTools()
|
|
|
|
//
|
|
|
|
// Check the state of the emulation and use it to tell which tools are available or not.
|
|
|
|
void UpdateTools()
|
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
ScrapRef theScrap;
|
|
|
|
ScrapFlavorFlags theScrapFlags;
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
GetCurrentScrap(&theScrap);
|
2002-11-14 04:40:11 +03:00
|
|
|
|
|
|
|
// If keyboard mapping is on AND there is text on the clipboard enable pasting
|
2006-02-22 22:18:29 +03:00
|
|
|
if (SIM->get_param_bool(BXPN_KBD_USEMAPPING)->get() &&
|
2008-02-16 01:05:43 +03:00
|
|
|
(GetScrapFlavorFlags(theScrap, kScrapFlavorTypeText, &theScrapFlags) == noErr))
|
2002-11-14 04:40:11 +03:00
|
|
|
{
|
|
|
|
EnableMenuItem(GetMenuRef(mEdit), iPaste);
|
|
|
|
EnableControl(bx_tool_pixmap[PASTE_TOOL_BUTTON].control);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DisableMenuItem(GetMenuRef(mEdit), iPaste);
|
|
|
|
DisableControl(bx_tool_pixmap[PASTE_TOOL_BUTTON].control);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Currently copy and snapshot aren't available if we aren't in text mode
|
|
|
|
if (screen_state == GRAPHIC_MODE) {
|
|
|
|
DisableMenuItem(GetMenuRef(mEdit), iCopy);
|
|
|
|
DisableMenuItem(GetMenuRef(mBochs), iSnapshot);
|
|
|
|
DisableControl(bx_tool_pixmap[COPY_TOOL_BUTTON].control);
|
|
|
|
DisableControl(bx_tool_pixmap[SNAPSHOT_TOOL_BUTTON].control);
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
EnableMenuItem(GetMenuRef(mEdit), iCopy);
|
|
|
|
EnableMenuItem(GetMenuRef(mBochs), iSnapshot);
|
|
|
|
EnableControl(bx_tool_pixmap[COPY_TOOL_BUTTON].control);
|
|
|
|
EnableControl(bx_tool_pixmap[SNAPSHOT_TOOL_BUTTON].control);
|
|
|
|
}
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
// User control active if keys defined
|
|
|
|
char *user_shortcut;
|
2006-02-22 22:43:55 +03:00
|
|
|
user_shortcut = SIM->get_param_string(BXPN_USER_SHORTCUT)->getptr();
|
2002-11-14 04:40:11 +03:00
|
|
|
if (user_shortcut[0] && (strcmp(user_shortcut, "none"))) {
|
|
|
|
EnableControl(bx_tool_pixmap[USER_TOOL_BUTTON].control);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DisableControl(bx_tool_pixmap[USER_TOOL_BUTTON].control);
|
|
|
|
}
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
// Config panel only available if user has a terminal or equivalent
|
|
|
|
if(isatty(STDIN_FILENO))
|
|
|
|
{
|
|
|
|
EnableControl(bx_tool_pixmap[CONFIGURE_TOOL_BUTTON].control);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DisableControl(bx_tool_pixmap[CONFIGURE_TOOL_BUTTON].control);
|
|
|
|
}
|
2002-10-18 15:46:19 +04:00
|
|
|
}
|
|
|
|
|
2001-09-26 04:31:41 +04:00
|
|
|
// HideTools()
|
|
|
|
//
|
|
|
|
// Hides the Bochs toolbar
|
|
|
|
|
|
|
|
void HideTools()
|
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
HideWindow(toolwin);
|
2002-09-30 18:03:20 +04:00
|
|
|
#if 0
|
2002-11-14 04:40:11 +03:00
|
|
|
if (menubarVisible)
|
|
|
|
{
|
|
|
|
MoveWindow(win, gLeft, gMinTop, false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
MoveWindow(hidden, gLeft, gMinTop, false);
|
|
|
|
}
|
2002-09-30 18:03:20 +04:00
|
|
|
#endif
|
2002-11-14 04:40:11 +03:00
|
|
|
CheckMenuItem(GetMenuHandle(mBochs), iTool, false);
|
|
|
|
HiliteWindow(win, true);
|
2001-09-26 04:31:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// ShowTools()
|
|
|
|
//
|
|
|
|
// Shows the Bochs toolbar
|
|
|
|
|
|
|
|
void ShowTools()
|
|
|
|
{
|
2002-09-30 18:03:20 +04:00
|
|
|
#if 0
|
2002-11-14 04:40:11 +03:00
|
|
|
if (menubarVisible)
|
|
|
|
{
|
|
|
|
MoveWindow(win, gLeft, gMaxTop, false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
MoveWindow(hidden, gLeft, gMaxTop, false);
|
|
|
|
}
|
2002-09-30 18:03:20 +04:00
|
|
|
#endif
|
2002-11-14 04:40:11 +03:00
|
|
|
ShowWindow(toolwin);
|
|
|
|
// theGui->show_headerbar();
|
|
|
|
CheckMenuItem(GetMenuHandle(mBochs), iTool, true);
|
|
|
|
HiliteWindow(win, true);
|
2001-09-26 04:31:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// HideMenubar()
|
|
|
|
//
|
|
|
|
// Hides the menubar (obviously)
|
|
|
|
|
|
|
|
void HideMenubar()
|
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
HideMenuBar();
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
HideWindow(win);
|
|
|
|
ShowWindow(backdrop);
|
|
|
|
hidden = win;
|
|
|
|
win = fullwin;
|
|
|
|
ShowWindow(win);
|
|
|
|
|
|
|
|
SelectWindow(win);
|
|
|
|
menubarVisible = false;
|
|
|
|
CheckMenuItem(GetMenuHandle(mBochs), iMenuBar, false);
|
2001-09-26 04:31:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// ShowMenubar()
|
|
|
|
//
|
|
|
|
// Makes the menubar visible again so other programs will display correctly.
|
|
|
|
|
|
|
|
void ShowMenubar()
|
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
HideWindow(backdrop);
|
|
|
|
win = hidden;
|
|
|
|
hidden = fullwin;
|
|
|
|
HideWindow(hidden);
|
|
|
|
ShowWindow(win);
|
|
|
|
HiliteWindow(win, true);
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
ShowMenuBar();
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
menubarVisible = true;
|
|
|
|
CheckMenuItem(GetMenuHandle(mBochs), iMenuBar, true);
|
2001-09-26 04:31:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void HideConsole()
|
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
// HideWindow(SouixWin);
|
|
|
|
CheckMenuItem(GetMenuHandle(mBochs), iConsole, false);
|
2001-09-26 04:31:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ShowConsole()
|
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
// ShowWindow(SouixWin);
|
|
|
|
// SelectWindow(SouixWin);
|
|
|
|
CheckMenuItem(GetMenuHandle(mBochs), iConsole, true);
|
2001-09-26 04:31:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// CreateKeyMap()
|
|
|
|
//
|
|
|
|
// Create a KCHR data structure to map Mac virtual key codes to Bochs key codes
|
|
|
|
|
|
|
|
void CreateKeyMap(void)
|
|
|
|
{
|
2002-11-14 04:40:11 +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,
|
2003-10-04 00:58:23 +04:00
|
|
|
BX_KEY_LEFT_BACKSLASH,
|
2002-11-14 04:40:11 +03:00
|
|
|
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,
|
2003-10-04 00:58:23 +04:00
|
|
|
BX_KEY_KP_ENTER,
|
2002-11-14 04:40:11 +03:00
|
|
|
BX_KEY_ESC,
|
2003-10-04 00:58:23 +04:00
|
|
|
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)
|
2002-11-14 04:40:11 +03:00
|
|
|
0, // 0x40
|
2003-10-04 00:58:23 +04:00
|
|
|
BX_KEY_KP_DELETE, // KP_PERIOD
|
|
|
|
0, // 0x42 (move right/multiply)
|
2002-11-14 04:40:11 +03:00
|
|
|
BX_KEY_KP_MULTIPLY,
|
|
|
|
0, // 0x44
|
|
|
|
BX_KEY_KP_ADD,
|
2003-10-04 00:58:23 +04:00
|
|
|
0, // 0x46 (move left/add)
|
|
|
|
BX_KEY_NUM_LOCK,
|
|
|
|
0, // 0x48 (move down/equals)
|
2002-11-14 04:40:11 +03:00
|
|
|
0, // 0x49
|
|
|
|
0, // 0x4A
|
|
|
|
BX_KEY_KP_DIVIDE,
|
|
|
|
BX_KEY_KP_ENTER,
|
2003-10-04 00:58:23 +04:00
|
|
|
0, // 0x4D (move up/divide)
|
2002-11-14 04:40:11 +03:00
|
|
|
BX_KEY_KP_SUBTRACT,
|
|
|
|
0, // 0x4F
|
|
|
|
0, // 0x50
|
2003-10-04 00:58:23 +04:00
|
|
|
BX_KEY_EQUALS, // 0x51 (kp equals)
|
|
|
|
BX_KEY_KP_INSERT, // 0x52 (kp 0)
|
|
|
|
BX_KEY_KP_END, // 0x53 (kp 1)
|
2002-11-14 04:40:11 +03:00
|
|
|
BX_KEY_KP_DOWN, // 0x54 (kp 2)
|
2003-10-04 00:58:23 +04:00
|
|
|
BX_KEY_KP_PAGE_DOWN, // 0x55 (kp 3)
|
2002-11-14 04:40:11 +03:00
|
|
|
BX_KEY_KP_LEFT, // 0x56 (kp 4)
|
|
|
|
BX_KEY_KP_5,
|
|
|
|
BX_KEY_KP_RIGHT, // 0x58 (kp 6)
|
2003-10-04 00:58:23 +04:00
|
|
|
BX_KEY_KP_HOME, // 0x59 (kp 7)
|
2002-11-14 04:40:11 +03:00
|
|
|
0, // 0x5A
|
|
|
|
BX_KEY_KP_UP, // 0x5B (kp 8)
|
2003-10-04 00:58:23 +04:00
|
|
|
BX_KEY_KP_PAGE_UP, // 0x5C (kp 9)
|
2002-11-14 04:40:11 +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
|
2003-10-04 00:58:23 +04:00
|
|
|
BX_KEY_PRINT, // 0x69 (print screen)
|
2002-11-14 04:40:11 +03:00
|
|
|
0, // 0x6A
|
2003-10-04 00:58:23 +04:00
|
|
|
BX_KEY_SCRL_LOCK, // 0x6B (scroll lock)
|
2002-11-14 04:40:11 +03:00
|
|
|
0, // 0x6C
|
|
|
|
BX_KEY_F10,
|
2003-10-04 00:58:23 +04:00
|
|
|
BX_KEY_MENU, // 0x6E
|
2002-11-14 04:40:11 +03:00
|
|
|
BX_KEY_F12,
|
|
|
|
0, // 0x70
|
2003-10-04 00:58:23 +04:00
|
|
|
BX_KEY_PAUSE, // 0x71 (pause)
|
2002-11-14 04:40:11 +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"));
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
BlockMove(KCHRHeader, KCHR, sizeof(KCHRHeader));
|
|
|
|
BlockMove(KCHRTable, Ptr(KCHR + sizeof(KCHRHeader)), sizeof(KCHRTable));
|
2001-09-26 04:31:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// CreateVGAFont()
|
|
|
|
//
|
|
|
|
// Create an array of PixMaps for the PC screen font
|
|
|
|
|
2007-03-23 11:30:22 +03:00
|
|
|
void CreateVGAFont(unsigned char *vga_charmap)
|
2001-09-26 04:31:41 +04:00
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
int i, x;
|
|
|
|
unsigned char *fontData, curPixel;
|
|
|
|
long row_bytes, bytecount;
|
2007-03-23 11:30:22 +03:00
|
|
|
|
|
|
|
SetRect(&srcTextRect, 0, 0, font_width, font_height);
|
2002-11-14 04:40:11 +03:00
|
|
|
for (i=0; i<256; i++)
|
|
|
|
{
|
2007-03-23 11:30:22 +03:00
|
|
|
if(vgafont[i] != NULL) free(vgafont[i]);
|
|
|
|
vgafont[i] = CreateBitMap(font_width, font_height);
|
2002-11-14 04:40:11 +03:00
|
|
|
row_bytes = (*(vgafont[i])).rowBytes;
|
2007-03-23 11:30:22 +03:00
|
|
|
bytecount = row_bytes * font_height;
|
2002-11-14 04:40:11 +03:00
|
|
|
fontData = (unsigned char *)NewPtrClear(bytecount);
|
|
|
|
|
2007-03-23 11:30:22 +03:00
|
|
|
for (x=0; x<font_height; x++)
|
2002-11-14 04:40:11 +03:00
|
|
|
{
|
|
|
|
//curPixel = ~(bx_vgafont[i].data[x]);
|
2007-03-23 11:30:22 +03:00
|
|
|
curPixel = (vga_charmap[(i*32) + x]);
|
|
|
|
fontData[x*row_bytes] = curPixel;
|
|
|
|
fontData[x*row_bytes + 1] = curPixel << 7;
|
2002-11-14 04:40:11 +03:00
|
|
|
}
|
|
|
|
vgafont[i]->baseAddr = Ptr(fontData);
|
|
|
|
}
|
2001-09-26 04:31:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// CreateBitMap()
|
|
|
|
// Allocate a new bitmap and fill in the fields with appropriate
|
|
|
|
// values.
|
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
BitMap *CreateBitMap(unsigned width, unsigned height)
|
2001-09-26 04:31:41 +04:00
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
BitMap *bm;
|
|
|
|
long row_bytes;
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
row_bytes = ((width + 31) >> 5) << 2;
|
2002-11-14 04:40:11 +03:00
|
|
|
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.
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
return bm;
|
2001-09-26 04:31:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// CreatePixMap()
|
|
|
|
// Allocate a new pixmap handle and fill in the fields with appropriate
|
|
|
|
// values.
|
2007-03-23 11:30:22 +03:00
|
|
|
/*
|
2001-09-26 04:31:41 +04:00
|
|
|
PixMapHandle CreatePixMap(unsigned left, unsigned top, unsigned width,
|
2002-11-14 04:40:11 +03:00
|
|
|
unsigned height, unsigned depth, CTabHandle clut)
|
2001-09-26 04:31:41 +04:00
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
PixMapHandle pm;
|
|
|
|
long row_bytes;
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
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-07 21:28:50 +03:00
|
|
|
|
2001-09-26 04:31:41 +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-07 21:28:50 +03:00
|
|
|
|
2002-11-14 04:40:11 +03:00
|
|
|
return pm;
|
2007-03-23 11:30:22 +03:00
|
|
|
}*/
|
2001-09-26 04:31:41 +04:00
|
|
|
|
2021-01-30 21:32:52 +03:00
|
|
|
void bx_carbon_gui_c::mouse_enabled_changed_specific(bool val)
|
2001-09-26 04:31:41 +04:00
|
|
|
{
|
|
|
|
}
|
2002-09-30 18:03:20 +04:00
|
|
|
|
2006-08-03 20:01:23 +04:00
|
|
|
void bx_carbon_gui_c::beep_on(float frequency)
|
|
|
|
{
|
|
|
|
AlertSoundPlay();
|
2008-02-16 01:05:43 +03:00
|
|
|
BX_INFO(("Carbon Beep ON (frequency=%.2f)",frequency));
|
2006-08-03 20:01:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void bx_carbon_gui_c::beep_off()
|
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
BX_INFO(("Carbon Beep OFF"));
|
2006-08-03 20:01:23 +04:00
|
|
|
}
|
|
|
|
|
2002-09-30 18:03:20 +04:00
|
|
|
// we need to handle "ask" events so that PANICs are properly reported
|
|
|
|
static BxEvent * CarbonSiminterfaceCallback (void *theClass, BxEvent *event)
|
|
|
|
{
|
2002-11-14 04:40:11 +03:00
|
|
|
event->retcode = 0; // default return code
|
2008-02-07 21:28:50 +03:00
|
|
|
|
2007-03-23 11:30:22 +03:00
|
|
|
if(event->type == BX_ASYNC_EVT_LOG_MSG || event->type == BX_SYNC_EVT_LOG_ASK)
|
2002-11-14 04:40:11 +03:00
|
|
|
{
|
2006-08-08 21:10:30 +04:00
|
|
|
DialogRef alertDialog;
|
|
|
|
CFStringRef title;
|
|
|
|
CFStringRef exposition;
|
|
|
|
DialogItemIndex index;
|
|
|
|
AlertStdCFStringAlertParamRec alertParam = {0};
|
2002-11-14 04:40:11 +03:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
if(event->u.logmsg.prefix != NULL)
|
2006-08-08 21:10:30 +04:00
|
|
|
{
|
|
|
|
title = CFStringCreateWithCString(NULL, event->u.logmsg.prefix, kCFStringEncodingASCII);
|
|
|
|
exposition = CFStringCreateWithCString(NULL, event->u.logmsg.msg, kCFStringEncodingASCII);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
title = CFStringCreateWithCString(NULL, event->u.logmsg.msg, kCFStringEncodingASCII);
|
|
|
|
exposition = NULL;
|
|
|
|
}
|
2002-11-14 04:40:11 +03:00
|
|
|
|
2006-08-08 21:10:30 +04:00
|
|
|
alertParam.version = kStdCFStringAlertVersionOne;
|
|
|
|
alertParam.defaultText = CFSTR("Continue");
|
|
|
|
alertParam.cancelText = CFSTR("Quit");
|
|
|
|
alertParam.position = kWindowDefaultPosition;
|
|
|
|
alertParam.defaultButton = kAlertStdAlertOKButton;
|
|
|
|
alertParam.cancelButton = kAlertStdAlertCancelButton;
|
2002-11-14 04:40:11 +03:00
|
|
|
|
2006-08-08 21:10:30 +04:00
|
|
|
CreateStandardAlert(
|
|
|
|
kAlertCautionAlert,
|
|
|
|
title,
|
|
|
|
exposition, /* can be NULL */
|
|
|
|
&alertParam, /* can be NULL */
|
|
|
|
&alertDialog);
|
2002-11-14 04:40:11 +03:00
|
|
|
|
2006-08-08 21:10:30 +04:00
|
|
|
RunStandardAlert(
|
|
|
|
alertDialog,
|
|
|
|
NULL, /* can be NULL */
|
|
|
|
&index);
|
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
CFRelease(title);
|
2006-08-08 21:10:30 +04:00
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
if(exposition != NULL)
|
2006-08-08 21:10:30 +04:00
|
|
|
{
|
2008-02-16 01:05:43 +03:00
|
|
|
CFRelease(exposition);
|
2006-08-08 21:10:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// continue
|
2008-02-16 01:05:43 +03:00
|
|
|
if(index == kAlertStdAlertOKButton)
|
2006-08-08 21:10:30 +04:00
|
|
|
{
|
|
|
|
event->retcode = 0;
|
|
|
|
}
|
|
|
|
// quit
|
2008-02-16 01:05:43 +03:00
|
|
|
else if(index == kAlertStdAlertCancelButton)
|
2006-08-08 21:10:30 +04:00
|
|
|
{
|
|
|
|
event->retcode = 2;
|
|
|
|
}
|
|
|
|
#if 0
|
2008-02-16 01:05:43 +03:00
|
|
|
if(event->u.logmsg.prefix != NULL)
|
2006-08-08 21:10:30 +04:00
|
|
|
{
|
|
|
|
BX_INFO(("Callback log: Prefix: %s", event->u.logmsg.prefix));
|
|
|
|
}
|
|
|
|
BX_INFO(("Callback log: Message: %s", event->u.logmsg.msg));
|
|
|
|
#endif
|
|
|
|
return event;
|
2002-11-14 04:40:11 +03:00
|
|
|
}
|
2002-09-30 18:03:20 +04:00
|
|
|
|
2002-10-18 15:46:19 +04:00
|
|
|
#if 0
|
2002-11-14 04:40:11 +03:00
|
|
|
// Track down the message that exiting leaves...
|
|
|
|
switch(event->type)
|
|
|
|
{
|
|
|
|
case BX_SYNC_EVT_TICK:
|
|
|
|
case BX_SYNC_EVT_LOG_ASK:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
BX_INFO(("Callback tracing: Evt: %d (%s)", event->type,
|
|
|
|
((BX_EVT_IS_ASYNC(event->type))?"async":"sync")));
|
|
|
|
}
|
2002-10-18 15:46:19 +04:00
|
|
|
#endif
|
2006-08-03 20:01:23 +04:00
|
|
|
if (old_callback != NULL) {
|
|
|
|
return (*old_callback)(old_callback_arg, event);
|
|
|
|
} else {
|
|
|
|
return event;
|
|
|
|
}
|
2002-09-30 18:03:20 +04:00
|
|
|
}
|
2002-11-19 08:47:45 +03:00
|
|
|
#endif /* if BX_WITH_CARBON */
|