Merged Carbon GUI patch by Dave Poirier

This commit is contained in:
Stanislav Shwartsman 2007-03-23 08:30:22 +00:00
parent 1ec33ec518
commit 5c57577f32

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: carbon.cc,v 1.33 2006-08-08 17:10:30 vruppert Exp $
////////////////////////////////////////////////////////////////////////
// $Id: carbon.cc,v 1.34 2007-03-23 08:30:22 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -108,8 +108,8 @@ const MenuCommand kCommandReset = FOUR_CHAR_CODE ('RSET');
#define SLEEP_TIME 0 // Number of ticks to surrender the processor during a WaitNextEvent()
// Change this to 15 or higher if you don't want Bochs to hog the processor!
#define FONT_WIDTH 8
#define FONT_HEIGHT 16
int font_width;
int font_height;
#define WINBITMAP(w) GetPortBitMapForCopyBits(GetWindowPort(w)) // (((GrafPtr)(w))->portBits)
@ -208,7 +208,7 @@ void CreateTile(void);
void CreateMenus(void);
void CreateWindows(void);
void CreateKeyMap(void);
void CreateVGAFont(void);
void CreateVGAFont(unsigned char *vga_charmap);
BitMap *CreateBitMap(unsigned width, unsigned height);
PixMapHandle CreatePixMap(unsigned left, unsigned top, unsigned width,
unsigned height, unsigned depth, CTabHandle clut);
@ -293,6 +293,7 @@ pascal OSStatus CEvtHandleWindowEmulatorClick (EventHandlerCallRef nextHandler,
//{
// SelectWindow(win);
//}
if (keyModifiers & cmdKey)
mouse_button_state |= 0x02;
else
@ -809,9 +810,14 @@ void CreateWindows(void)
void bx_carbon_gui_c::specific_init(int argc, char **argv, unsigned tilewidth, unsigned tileheight,
unsigned headerbar_y)
{
int i;
put("MGUI");
InitToolbox();
font_width = 8;
font_height = 16;
gheaderbar_y = headerbar_y + TOOL_MARGIN_SPACE + TOOL_MARGIN_SPACE;
CreateKeyMap();
@ -819,11 +825,13 @@ void bx_carbon_gui_c::specific_init(int argc, char **argv, unsigned tilewidth, u
gCTable = GetCTable(128);
BX_ASSERT (gCTable != NULL);
CTabChanged(gCTable); //(*gCTable)->ctSeed = GetCTSeed();
SetRect(&srcTextRect, 0, 0, FONT_WIDTH, FONT_HEIGHT);
SetRect(&srcTileRect, 0, 0, tilewidth, tileheight);
for(i=0; i<256; i++) {
vgafont[i] = NULL;
}
CreateMenus();
CreateVGAFont();
CreateVGAFont(vga_charmap);
CreateTile();
CreateWindows();
@ -1162,6 +1170,11 @@ void bx_carbon_gui_c::text_update(Bit8u *old_text, Bit8u *new_text,
screen_state = TEXT_MODE;
if( charmap_updated == 1 ) {
CreateVGAFont(vga_charmap);
charmap_updated = 0;
}
/* if (gOffWorld != NULL) //(SIM->get_param_bool(BXPN_PRIVATE_COLORMAP)->get ())
{
GetGWorld(&savePort, &saveDevice);
@ -1172,7 +1185,7 @@ void bx_carbon_gui_c::text_update(Bit8u *old_text, Bit8u *new_text,
SetPortWindowPort(win);
ncols = width/8;
ncols = width/font_width;
//current cursor position
cursori = (cursor_y*ncols + cursor_x)*2;
@ -1206,14 +1219,15 @@ void bx_carbon_gui_c::text_update(Bit8u *old_text, Bit8u *new_text,
RGBBackColor(&bgColor);
}
x = ((i/2) % ncols)*FONT_WIDTH;
y = ((i/2) / ncols)*FONT_HEIGHT;
x = ((i/2) % ncols)*font_width;
y = ((i/2) / ncols)*font_height;
SetRect(&destRect, x, y,
x+FONT_WIDTH, y+FONT_HEIGHT);
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));
@ -1235,8 +1249,7 @@ void bx_carbon_gui_c::text_update(Bit8u *old_text, Bit8u *new_text,
windowUpdatesPending = true;
}
int
bx_carbon_gui_c::get_clipboard_text(Bit8u **bytes, Bit32s *nbytes)
int bx_carbon_gui_c::get_clipboard_text(Bit8u **bytes, Bit32s *nbytes)
{
ScrapRef theScrap;
ScrapFlavorFlags theScrapFlags;
@ -1263,8 +1276,7 @@ bx_carbon_gui_c::get_clipboard_text(Bit8u **bytes, Bit32s *nbytes)
return (err == noErr);
}
int
bx_carbon_gui_c::set_clipboard_text(char *text_snapshot, Bit32u len)
int bx_carbon_gui_c::set_clipboard_text(char *text_snapshot, Bit32u len)
{
ScrapRef theScrap;
@ -1433,14 +1445,15 @@ void bx_carbon_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight,
vga_bpp = bpp;
CreateTile();
}
if (fheight > 0) {
if (fwidth != 8) {
x = x * 8 / fwidth;
}
if (fheight != 16) {
y = y * 16 / fheight;
if( fwidth != font_width || fheight != font_height ) {
font_width = fwidth;
font_height = fheight;
CreateVGAFont(vga_charmap);
}
}
if (x != width || y != height)
{
#if 1
@ -1495,7 +1508,7 @@ unsigned bx_carbon_gui_c::create_bitmap(const unsigned char *bmap, unsigned xdim
long row_bytes, bytecount;
bx_cicn[numPixMaps] = GetCIcon(numPixMaps+128);
BX_ASSERT(bx_cicn[numPixMaps]);
// BX_ASSERT(bx_cicn[numPixMaps]);
numPixMaps++;
@ -1974,24 +1987,27 @@ void CreateKeyMap(void)
//
// Create an array of PixMaps for the PC screen font
void CreateVGAFont(void)
void CreateVGAFont(unsigned char *vga_charmap)
{
int i, x;
unsigned char *fontData, curPixel;
long row_bytes, bytecount;
SetRect(&srcTextRect, 0, 0, font_width, font_height);
for (i=0; i<256; i++)
{
vgafont[i] = CreateBitMap(FONT_WIDTH, FONT_HEIGHT);
if(vgafont[i] != NULL) free(vgafont[i]);
vgafont[i] = CreateBitMap(font_width, font_height);
row_bytes = (*(vgafont[i])).rowBytes;
bytecount = row_bytes * FONT_HEIGHT;
bytecount = row_bytes * font_height;
fontData = (unsigned char *)NewPtrClear(bytecount);
for (x=0; x<16; x++)
for (x=0; x<font_height; x++)
{
//curPixel = ~(bx_vgafont[i].data[x]);
curPixel = (bx_vgafont[i].data[x]);
fontData[x*row_bytes] = reverse_bitorder(curPixel);
curPixel = (vga_charmap[(i*32) + x]);
fontData[x*row_bytes] = curPixel;
fontData[x*row_bytes + 1] = curPixel << 7;
}
vgafont[i]->baseAddr = Ptr(fontData);
}
@ -2021,7 +2037,7 @@ BitMap *CreateBitMap(unsigned width, unsigned height)
// CreatePixMap()
// Allocate a new pixmap handle and fill in the fields with appropriate
// values.
/*
PixMapHandle CreatePixMap(unsigned left, unsigned top, unsigned width,
unsigned height, unsigned depth, CTabHandle clut)
{
@ -2045,7 +2061,7 @@ PixMapHandle CreatePixMap(unsigned left, unsigned top, unsigned width,
// use one we created earlier.
return pm;
}
}*/
unsigned char reverse_bitorder(unsigned char b)
{