2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2011-02-25 01:05:47 +03:00
|
|
|
// $Id$
|
2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2009-12-04 23:02:12 +03:00
|
|
|
// Copyright (C) 2001-2009 The Bochs Project
|
2001-04-10 05:04:59 +04:00
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
2009-02-08 12:05:52 +03:00
|
|
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
|
2002-10-25 01:07:56 +04:00
|
|
|
// Define BX_PLUGGABLE in files that can be compiled into plugins. For
|
2008-02-06 01:57:43 +03:00
|
|
|
// platforms that require a special tag on exported symbols, BX_PLUGGABLE
|
2002-10-25 01:07:56 +04:00
|
|
|
// is used to know when we are exporting symbols and when we are importing.
|
|
|
|
#define BX_PLUGGABLE
|
|
|
|
|
2002-11-22 18:14:39 +03:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2010-02-26 17:18:19 +03:00
|
|
|
#include "param_names.h"
|
2002-11-19 08:47:45 +03:00
|
|
|
#include "bochs.h"
|
2004-06-19 19:20:15 +04:00
|
|
|
#include "iodev.h"
|
2002-11-19 08:47:45 +03:00
|
|
|
#if BX_WITH_BEOS
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
#include <app/Application.h>
|
|
|
|
#include <interface/Window.h>
|
|
|
|
#include <interface/View.h>
|
|
|
|
#include <interface/Screen.h>
|
|
|
|
#include <interface/Bitmap.h>
|
|
|
|
#include <interface/GraphicsDefs.h>
|
|
|
|
|
2001-12-07 21:52:24 +03:00
|
|
|
//#include "icon_bochs.h"
|
2001-04-10 05:04:59 +04:00
|
|
|
#include "font/vga.bitmap.h"
|
|
|
|
|
2002-10-25 01:07:56 +04:00
|
|
|
class bx_beos_gui_c : public bx_gui_c {
|
|
|
|
public:
|
|
|
|
bx_beos_gui_c (void) {}
|
|
|
|
DECLARE_GUI_VIRTUAL_METHODS()
|
|
|
|
};
|
|
|
|
|
|
|
|
// declare one instance of the gui object and call macro to insert the
|
|
|
|
// plugin code
|
|
|
|
static bx_beos_gui_c *theGui = NULL;
|
|
|
|
IMPLEMENT_GUI_PLUGIN_CODE(beos)
|
2001-09-04 18:30:41 +04:00
|
|
|
|
2002-10-27 01:03:21 +04:00
|
|
|
#define LOG_THIS theGui->
|
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
#define PAD_NEAREST(n, quantum) ((((n) + ((quantum) - 1)) / (n)) * (n))
|
2001-12-07 21:52:24 +03:00
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
class BochsApplication : public BApplication {
|
|
|
|
public:
|
|
|
|
BochsApplication();
|
2006-06-20 21:17:46 +04:00
|
|
|
};
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
class BochsWindow : public BWindow {
|
|
|
|
public:
|
|
|
|
BochsWindow(BRect frame);
|
|
|
|
virtual bool QuitRequested();
|
|
|
|
virtual void FrameResized(float width, float height);
|
2006-06-20 21:17:46 +04:00
|
|
|
};
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
class BochsView : public BView {
|
|
|
|
private:
|
2006-06-20 21:17:46 +04:00
|
|
|
BBitmap *backing_store;
|
|
|
|
BView *backing_view;
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
public:
|
|
|
|
BochsView(BRect frame, char *name);
|
|
|
|
~BochsView();
|
|
|
|
virtual void AttachedToWindow();
|
|
|
|
virtual void Draw(BRect updateRect);
|
|
|
|
virtual void KeyDown(const char *bytes, int32 numBytes);
|
|
|
|
virtual void KeyUp(const char *bytes, int32 numBytes);
|
|
|
|
virtual void MouseDown(BPoint point);
|
|
|
|
virtual void MouseUp(BPoint point);
|
|
|
|
virtual void MouseMoved(BPoint point,
|
|
|
|
uint32 transit, const BMessage *message);
|
2008-02-06 01:57:43 +03:00
|
|
|
void DrawBitmap(const BBitmap *aBitmap, BPoint where);
|
2001-04-10 05:04:59 +04:00
|
|
|
void FillRect(BRect r, pattern p = B_SOLID_HIGH);
|
|
|
|
void SetHighColor(uchar r, uchar g, uchar b, uchar a = 255);
|
|
|
|
void SetLowColor(uchar r, uchar g, uchar b, uchar a = 255);
|
|
|
|
void SetFont(const BFont *font, uint32 mask = B_FONT_ALL);
|
|
|
|
void set_text_colors(void);
|
|
|
|
void set_inv_text_colors(void);
|
|
|
|
void set_headerbar_colors(void);
|
2006-06-20 21:17:46 +04:00
|
|
|
};
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
|
|
|
|
void GUI_end(void);
|
|
|
|
void enq_key_event(Bit32u key, Bit32u press_release);
|
|
|
|
Bit32u deq_key_event(void);
|
|
|
|
#define SCANCODE_BUFSIZE 20
|
|
|
|
static Bit32u keyevents[SCANCODE_BUFSIZE];
|
|
|
|
static unsigned head=0, tail=0;
|
|
|
|
static bool view_attached = 0;
|
|
|
|
|
|
|
|
static BochsApplication *myApplication = NULL;
|
|
|
|
static BochsWindow *aWindow = NULL;
|
|
|
|
static BochsView *aView = NULL;
|
|
|
|
static BView *canvas = NULL;
|
|
|
|
static uint8 cmap_index[256]; // indeces into system colormap
|
|
|
|
|
|
|
|
static BRect rect;
|
|
|
|
static BPoint image_origin;
|
|
|
|
static BBitmap *image = NULL;
|
|
|
|
static BScreen *screen;
|
|
|
|
static unsigned long rowsize_padded=0;
|
|
|
|
static uint8 *rawdata = NULL;
|
|
|
|
|
2008-01-26 03:00:31 +03:00
|
|
|
static unsigned int text_rows=25, text_cols=80;
|
2001-04-10 05:04:59 +04:00
|
|
|
static unsigned font_width, font_height;
|
|
|
|
static Bit8u blank_line[80];
|
|
|
|
static unsigned dimension_x, dimension_y;
|
|
|
|
|
|
|
|
//static unsigned imDepth, imWide, imBPP;
|
|
|
|
|
|
|
|
// current cursor coordinates
|
2001-12-07 21:52:24 +03:00
|
|
|
//IRA=> Start
|
|
|
|
static BPoint current;
|
|
|
|
static BPoint previous;
|
|
|
|
static Bit8u mouse_button_state = 0;
|
|
|
|
//IRA=> End
|
2001-04-10 05:04:59 +04:00
|
|
|
//static int prev_x=-1, prev_y=-1;
|
|
|
|
//static int current_x=-1, current_y=-1;
|
|
|
|
|
|
|
|
static unsigned prev_block_cursor_x=0;
|
|
|
|
static unsigned prev_block_cursor_y=0;
|
|
|
|
|
|
|
|
static void headerbar_click(int x, int y);
|
|
|
|
|
|
|
|
Bit8u ascii_to_scancode[0x7f] = {
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0x39, 0x02, 0x28, 0x04, 0x05, 0x06, 0x08, 0x28, /* !"#$%&' */
|
|
|
|
0x0a, 0x0b, 0x09, 0x0d, 0x33, 0x0c, 0x34, 0x35, /* ()*+,-./ */
|
|
|
|
0x0b, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, /* 01234567 */
|
|
|
|
0x09, 0x0a, 0x27, 0x27, 0x33, 0x0d, 0x34, 0x35, /* 89:;<=>? */
|
|
|
|
0x03, 0x1e, 0x30, 0x2e, 0x20, 0x12, 0x21, 0x22, /* @ABCDEFG */
|
|
|
|
0x23, 0x17, 0x24, 0x25, 0x26, 0x32, 0x31, 0x18, /* HIJKLMNO */
|
|
|
|
0x19, 0x10, 0x13, 0x1f, 0x14, 0x16, 0x2f, 0x11, /* PQRSTUVW */
|
|
|
|
0x2d, 0x15, 0x2c, 0x1a, 0x2b, 0x1b, 0x07, 0x0c, /* XYZ[\]^_ */
|
|
|
|
0x29, 0x1e, 0x30, 0x2e, 0x20, 0x12, 0x21, 0x22, /* `abcdefg */
|
|
|
|
0x23, 0x17, 0x24, 0x25, 0x26, 0x32, 0x31, 0x18, /* hijklmno */
|
|
|
|
0x19, 0x10, 0x13, 0x1f, 0x14, 0x16, 0x2f, 0x11, /* pqrstuvw */
|
|
|
|
0x2d, 0x15, 0x2c, 0x1a, 0x2b, 0x1b, 0x29 /* xyz{|}~ */
|
2006-06-20 21:17:46 +04:00
|
|
|
};
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
extern Bit8u graphics_snapshot[32 * 1024];
|
|
|
|
//extern pc_keyb_c *pc_keyboard;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unsigned col_vals[256], curr_foreground, curr_background;
|
|
|
|
|
|
|
|
static unsigned x_tilesize, y_tilesize;
|
|
|
|
|
2010-01-24 15:46:42 +03:00
|
|
|
static struct {
|
2001-04-10 05:04:59 +04:00
|
|
|
BBitmap *bmap;
|
|
|
|
unsigned xdim;
|
|
|
|
unsigned ydim;
|
2006-06-20 21:17:46 +04:00
|
|
|
} bx_bitmaps[BX_MAX_PIXMAPS];
|
2010-01-24 15:46:42 +03:00
|
|
|
static unsigned bx_bitmap_entries = 0;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
static struct {
|
|
|
|
BBitmap *bitmap;
|
|
|
|
unsigned xdim;
|
|
|
|
unsigned ydim;
|
|
|
|
unsigned xorigin;
|
|
|
|
unsigned yorigin;
|
|
|
|
unsigned alignment;
|
|
|
|
void (*f)(void);
|
2010-01-24 15:46:42 +03:00
|
|
|
} bx_headerbar_entry[BX_MAX_HEADERBAR_ENTRIES];
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
static unsigned bx_headerbar_y = 0;
|
|
|
|
static unsigned bx_headerbar_entries = 0;
|
|
|
|
static unsigned bx_bitmap_left_xorigin = 0; // pixels from left
|
|
|
|
static unsigned bx_bitmap_right_xorigin = 0; // pixels from right
|
|
|
|
|
|
|
|
static void headerbar_click(int x, int y);
|
|
|
|
static unsigned char reverse_bitorder(unsigned char b);
|
|
|
|
static void create_vga_font(void);
|
|
|
|
static BBitmap *vgafont[256];
|
|
|
|
|
2010-01-24 15:46:42 +03:00
|
|
|
void bx_beos_gui_c::specific_init(int argc, char **argv,
|
2001-04-10 05:04:59 +04:00
|
|
|
unsigned tilewidth, unsigned tileheight,
|
|
|
|
unsigned header_bar_y)
|
|
|
|
{
|
2006-06-20 21:17:46 +04:00
|
|
|
UNUSED(argc);
|
|
|
|
UNUSED(argv);
|
2005-04-29 23:06:24 +04:00
|
|
|
|
2002-10-25 01:07:56 +04:00
|
|
|
put("BGUI");
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2006-02-22 00:35:09 +03:00
|
|
|
if (SIM->get_param_bool(BXPN_PRIVATE_COLORMAP)->get()) {
|
2008-02-16 01:05:43 +03:00
|
|
|
BX_INFO(("BeOS: private_colormap option not handled yet."));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
x_tilesize = tilewidth;
|
|
|
|
y_tilesize = tileheight;
|
|
|
|
bx_headerbar_y = header_bar_y;
|
|
|
|
|
2005-04-29 23:06:24 +04:00
|
|
|
for (int i=0; i<80; i++) {
|
2001-04-10 05:04:59 +04:00
|
|
|
blank_line[i] = ' ';
|
2006-06-20 21:17:46 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
font_width = 8;
|
|
|
|
font_height = 16;
|
|
|
|
|
|
|
|
// width = columns * font_width;
|
|
|
|
// height = rows * font_height;
|
|
|
|
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_INFO(("font_width = %u", (unsigned) font_width));
|
|
|
|
BX_INFO(("font_height = %u", (unsigned) font_height));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
// Create pixmap of depth 1 (bitmap) for icon
|
|
|
|
// icon_pixmap = XCreateBitmapFromData(bx_x_display, win,
|
|
|
|
// (char *) bochs_icon_bits, bochs_icon_width, bochs_icon_height);
|
|
|
|
|
|
|
|
curr_background = 0;
|
|
|
|
// XSetBackground(bx_x_display, gc, col_vals[curr_background]);
|
|
|
|
curr_foreground = 1;
|
|
|
|
// XSetForeground(bx_x_display, gc, col_vals[curr_foreground]);
|
2008-02-16 01:05:43 +03:00
|
|
|
//XGrabPointer(bx_x_display, win, True, 0, GrabModeAsync, GrabModeAsync,
|
|
|
|
// win, None, CurrentTime);
|
2001-04-10 05:04:59 +04:00
|
|
|
//XFlush(bx_x_display);
|
|
|
|
|
|
|
|
myApplication = new BochsApplication();
|
|
|
|
|
|
|
|
// wait until window on screen
|
|
|
|
while (1) {
|
|
|
|
aWindow->Lock();
|
|
|
|
if (aWindow->IsHidden()) {
|
2006-06-20 21:17:46 +04:00
|
|
|
aWindow->Unlock();
|
|
|
|
continue;
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
aWindow->Unlock();
|
|
|
|
break;
|
2006-06-20 21:17:46 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
screen = new BScreen;
|
|
|
|
// start out with all color map indeces pointing to Black
|
|
|
|
cmap_index[0] = screen->IndexForColor(0, 0, 0);
|
|
|
|
for (unsigned i=1; i<256; i++) {
|
|
|
|
cmap_index[i] = cmap_index[0];
|
2006-06-20 21:17:46 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
rect.Set(0,0, x_tilesize-1, y_tilesize-1);
|
|
|
|
image = new BBitmap(rect, B_COLOR_8_BIT);
|
|
|
|
rowsize_padded = PAD_NEAREST(x_tilesize, sizeof(int32));
|
|
|
|
rawdata = new uint8[rowsize_padded * y_tilesize];
|
|
|
|
|
|
|
|
create_vga_font();
|
|
|
|
}
|
|
|
|
|
2006-06-20 21:17:46 +04:00
|
|
|
void bx_beos_gui_c::handle_events(void)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
|
|
|
Bit32u key;
|
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
while (head != tail) {
|
2001-04-10 05:04:59 +04:00
|
|
|
key = deq_key_event();
|
2002-10-25 01:07:56 +04:00
|
|
|
DEV_kbd_gen_scancode(key);
|
2006-06-20 21:17:46 +04:00
|
|
|
}
|
2001-12-07 21:52:24 +03:00
|
|
|
//IRA=> Start
|
|
|
|
if (aView) {
|
|
|
|
unsigned long buttons;
|
|
|
|
aView->LockLooper();
|
2008-02-06 01:57:43 +03:00
|
|
|
aView->GetMouse(¤t, &buttons, false);
|
2006-06-20 21:17:46 +04:00
|
|
|
aView->UnlockLooper();
|
|
|
|
|
|
|
|
Bit8u newstate = 0; //please note: 2nd and 3rd button are mapped the same
|
|
|
|
if (buttons & B_PRIMARY_MOUSE_BUTTON)
|
|
|
|
newstate |= 0x01;
|
|
|
|
if (buttons & B_SECONDARY_MOUSE_BUTTON)
|
|
|
|
newstate |= 0x02;
|
|
|
|
if (buttons & B_TERTIARY_MOUSE_BUTTON)
|
|
|
|
newstate |= 0x02;
|
2008-02-06 01:57:43 +03:00
|
|
|
|
2006-06-20 21:17:46 +04:00
|
|
|
if (current != previous || mouse_button_state != newstate) {
|
|
|
|
int dx = (int)(current.x - previous.x) *2;
|
|
|
|
int dy = -(int)((current.y - previous.y) *2);
|
2008-02-16 01:05:43 +03:00
|
|
|
DEV_mouse_motion(dx, dy, newstate);
|
2006-06-20 21:17:46 +04:00
|
|
|
mouse_button_state = newstate;
|
|
|
|
previous = current;
|
2001-12-07 21:52:24 +03:00
|
|
|
}
|
2006-06-20 21:17:46 +04:00
|
|
|
}
|
2001-12-07 21:52:24 +03:00
|
|
|
//IRA=> End
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2006-06-20 21:17:46 +04:00
|
|
|
void bx_beos_gui_c::flush(void)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2006-06-20 21:17:46 +04:00
|
|
|
if (view_attached) aView->Flush();
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2006-06-20 21:17:46 +04:00
|
|
|
void bx_beos_gui_c::clear_screen(void)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
|
|
|
aWindow->Lock();
|
|
|
|
aView->FillRect(BRect(0, bx_headerbar_y, dimension_x-1, dimension_y-1), B_SOLID_LOW);
|
|
|
|
aWindow->Unlock();
|
|
|
|
}
|
|
|
|
|
2006-06-20 21:17:46 +04:00
|
|
|
void bx_beos_gui_c::text_update(Bit8u *old_text, Bit8u *new_text,
|
2001-04-10 05:04:59 +04:00
|
|
|
unsigned long cursor_x, unsigned long cursor_y,
|
2008-01-26 03:00:31 +03:00
|
|
|
bx_vga_tminfo_t tm_info)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
|
|
|
unsigned i, x, y;
|
|
|
|
BPoint point;
|
|
|
|
unsigned char achar;
|
2008-01-26 03:00:31 +03:00
|
|
|
unsigned nchars;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
aWindow->Lock();
|
|
|
|
|
|
|
|
// Number of characters on screen, variable number of rows
|
2008-01-26 03:00:31 +03:00
|
|
|
nchars = text_cols * text_rows;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
// first draw over character at original block cursor location
|
2008-02-16 01:05:43 +03:00
|
|
|
if ((prev_block_cursor_y*text_cols + prev_block_cursor_x) < nchars) {
|
2008-01-26 03:00:31 +03:00
|
|
|
achar = new_text[(prev_block_cursor_y*text_cols + prev_block_cursor_x)*2];
|
2001-04-10 05:04:59 +04:00
|
|
|
point.Set(prev_block_cursor_x*8, prev_block_cursor_y*16 + bx_headerbar_y);
|
2008-02-16 01:05:43 +03:00
|
|
|
aView->DrawBitmap(vgafont[achar], point);
|
2006-06-20 21:17:46 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
for (i=0; i<nchars*2; i+=2) {
|
2006-06-20 21:17:46 +04:00
|
|
|
if ((old_text[i]!=new_text[i]) ||
|
|
|
|
(old_text[i+1]!=new_text[i+1]))
|
|
|
|
{
|
2001-04-10 05:04:59 +04:00
|
|
|
achar = new_text[i];
|
|
|
|
|
2008-01-26 03:00:31 +03:00
|
|
|
x = (i/2) % text_cols;
|
|
|
|
y = (i/2) / text_cols;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
point.Set(x*8, y*16 + bx_headerbar_y);
|
2008-02-16 01:05:43 +03:00
|
|
|
aView->DrawBitmap(vgafont[achar], point);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
2006-06-20 21:17:46 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
prev_block_cursor_x = cursor_x;
|
|
|
|
prev_block_cursor_y = cursor_y;
|
|
|
|
|
|
|
|
// now draw character at new block cursor location in reverse
|
2008-01-26 03:00:31 +03:00
|
|
|
if ((cursor_y*text_cols + cursor_x) < nchars) {
|
|
|
|
achar = new_text[(cursor_y*text_cols + cursor_x)*2];
|
2001-04-10 05:04:59 +04:00
|
|
|
point.Set(cursor_x*8, cursor_y*16 + bx_headerbar_y);
|
|
|
|
aView->set_inv_text_colors();
|
2008-02-16 01:05:43 +03:00
|
|
|
aView->DrawBitmap(vgafont[achar], point);
|
2001-04-10 05:04:59 +04:00
|
|
|
aView->set_text_colors();
|
2006-06-20 21:17:46 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
aWindow->Unlock();
|
|
|
|
}
|
|
|
|
|
2006-06-20 21:17:46 +04:00
|
|
|
int bx_beos_gui_c::get_clipboard_text(Bit8u **bytes, Bit32s *nbytes)
|
2002-03-16 14:30:06 +03:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-06-20 21:17:46 +04:00
|
|
|
int bx_beos_gui_c::set_clipboard_text(char *text_snapshot, Bit32u len)
|
2002-03-15 19:45:10 +03:00
|
|
|
{
|
2002-03-16 14:30:06 +03:00
|
|
|
return 0;
|
2002-03-15 19:45:10 +03:00
|
|
|
}
|
|
|
|
|
2006-06-20 21:17:46 +04:00
|
|
|
void bx_beos_gui_c::graphics_tile_update(Bit8u *tile, unsigned x0, unsigned y0)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
|
|
|
for (unsigned y=0; y<y_tilesize; y++) {
|
|
|
|
for (unsigned x=0; x<x_tilesize; x++) {
|
|
|
|
rawdata[y*rowsize_padded + x] = cmap_index[ tile[y*x_tilesize + x] ];
|
|
|
|
}
|
2006-06-20 21:17:46 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
aWindow->Lock();
|
|
|
|
image->SetBits(rawdata, rowsize_padded * y_tilesize, 0, B_COLOR_8_BIT);
|
|
|
|
image_origin.Set(x0, y0 + bx_headerbar_y);
|
|
|
|
|
2006-06-20 21:17:46 +04:00
|
|
|
aView->DrawBitmap(image, image_origin);
|
2001-04-10 05:04:59 +04:00
|
|
|
aWindow->Unlock();
|
|
|
|
}
|
|
|
|
|
2006-06-20 21:17:46 +04:00
|
|
|
bx_bool bx_beos_gui_c::palette_change(unsigned index, unsigned red, unsigned green, unsigned blue)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2006-06-20 21:17:46 +04:00
|
|
|
cmap_index[index] = screen->IndexForColor(red, green, blue);
|
2001-04-10 05:04:59 +04:00
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
2006-06-20 21:17:46 +04:00
|
|
|
void bx_beos_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight, unsigned fwidth, unsigned bpp)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2003-06-28 12:04:31 +04:00
|
|
|
if (bpp > 8) {
|
|
|
|
BX_PANIC(("%d bpp graphics mode not supported yet", bpp));
|
|
|
|
}
|
2002-04-20 11:19:35 +04:00
|
|
|
if (fheight > 0) {
|
2008-01-26 03:00:31 +03:00
|
|
|
text_cols = x / fwidth;
|
|
|
|
text_rows = y / fheight;
|
2003-05-11 19:07:54 +04:00
|
|
|
if (fwidth != 8) {
|
|
|
|
x = x * 8 / fwidth;
|
|
|
|
}
|
2002-04-20 11:19:35 +04:00
|
|
|
if (fheight != 16) {
|
|
|
|
y = y * 16 / fheight;
|
|
|
|
}
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
aWindow->Lock();
|
|
|
|
aWindow->ResizeTo(x, y + bx_headerbar_y);
|
|
|
|
aWindow->Unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////
|
|
|
|
|
2006-06-20 21:17:46 +04:00
|
|
|
void GUI_end()
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
|
|
|
//myApplication->Run();
|
|
|
|
delete(myApplication);
|
|
|
|
}
|
|
|
|
|
|
|
|
BochsApplication::BochsApplication()
|
|
|
|
: BApplication("application/x-vnd.Be-Bochs")
|
|
|
|
{
|
|
|
|
BRect aRect;
|
|
|
|
|
|
|
|
int left, right, top, bottom;
|
|
|
|
left = 5;
|
|
|
|
top = 80;
|
|
|
|
dimension_x = 640;
|
|
|
|
dimension_y = 480 + bx_headerbar_y;
|
|
|
|
right = left + dimension_x - 1;
|
|
|
|
bottom = top + dimension_y - 1;
|
|
|
|
|
|
|
|
// set up a rectangle and instantiate a new window
|
|
|
|
aRect.Set(left, top, right, bottom);
|
|
|
|
aWindow = new BochsWindow(aRect);
|
|
|
|
|
|
|
|
// set up a rectangle and instantiate a new view
|
|
|
|
// view rect should be same size as window rect but with left top at (0, 0)
|
|
|
|
aRect.OffsetTo(B_ORIGIN);
|
|
|
|
aView = new BochsView(aRect, "BochsView");
|
|
|
|
aView->SetViewColor(0, 0, 0);
|
|
|
|
|
|
|
|
aView->set_text_colors();
|
|
|
|
|
|
|
|
// add view to window
|
|
|
|
aWindow->AddChild(aView);
|
|
|
|
|
|
|
|
// make window visible
|
|
|
|
aWindow->Show();
|
|
|
|
}
|
|
|
|
|
|
|
|
//void set_palette_entry(long i,rgb_color c);
|
|
|
|
|
|
|
|
BochsWindow::BochsWindow(BRect frame)
|
2001-12-07 21:52:24 +03:00
|
|
|
: BWindow(frame, "BeBochs V1.3.pre compiled Bernd Korz", B_TITLED_WINDOW, B_NOT_RESIZABLE)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BochsWindow::QuitRequested()
|
|
|
|
{
|
|
|
|
be_app->PostMessage(B_QUIT_REQUESTED);
|
|
|
|
return(TRUE);
|
|
|
|
}
|
|
|
|
|
2006-06-20 21:17:46 +04:00
|
|
|
void BochsWindow::FrameResized(float width, float height)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
|
|
|
dimension_x = unsigned(width);
|
|
|
|
dimension_y = unsigned(height) + bx_headerbar_y;
|
2002-10-25 01:07:56 +04:00
|
|
|
theGui->show_headerbar();
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------
|
|
|
|
|
|
|
|
BochsView::BochsView(BRect rect, char *name)
|
|
|
|
: BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW)
|
|
|
|
{
|
2006-06-20 21:17:46 +04:00
|
|
|
backing_store = new BBitmap(rect, B_BITMAP_ACCEPTS_VIEWS, B_COLOR_8_BIT);
|
|
|
|
backing_view = new BView(rect,"backing store", B_FOLLOW_ALL, B_WILL_DRAW);
|
|
|
|
backing_store->AddChild(backing_view);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2006-06-20 21:17:46 +04:00
|
|
|
void BochsView::set_text_colors(void)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
|
|
|
aView->SetHighColor(255, 255, 255);
|
|
|
|
aView->SetLowColor(0, 0, 0);
|
|
|
|
}
|
|
|
|
|
2006-06-20 21:17:46 +04:00
|
|
|
void BochsView::set_inv_text_colors(void)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
|
|
|
aView->SetHighColor(0, 0, 0);
|
|
|
|
aView->SetLowColor(255, 255, 255);
|
|
|
|
}
|
|
|
|
|
2006-06-20 21:17:46 +04:00
|
|
|
void BochsView::set_headerbar_colors(void)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
|
|
|
aView->SetHighColor(0, 0, 0);
|
|
|
|
aView->SetLowColor(255, 255, 255);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BochsView::AttachedToWindow()
|
|
|
|
{
|
|
|
|
BFont font(be_fixed_font);
|
|
|
|
|
|
|
|
aWindow->Lock();
|
|
|
|
font.SetSize(16);
|
|
|
|
font.SetFlags(B_DISABLE_ANTIALIASING);
|
|
|
|
aView->SetFont(&font);
|
|
|
|
|
|
|
|
aView->MakeFocus(true);
|
|
|
|
aWindow->Unlock();
|
|
|
|
|
|
|
|
view_attached = 1;
|
|
|
|
}
|
|
|
|
|
2006-06-20 21:17:46 +04:00
|
|
|
void BochsView::MouseDown(BPoint point)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
|
|
|
UNUSED(point);
|
|
|
|
if (point.y < BX_HEADER_BAR_Y) {
|
|
|
|
headerbar_click(int(point.x), int(point.y));
|
|
|
|
return;
|
2006-06-20 21:17:46 +04:00
|
|
|
}
|
|
|
|
BX_DEBUG(("mousedown()"));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2006-06-20 21:17:46 +04:00
|
|
|
void BochsView::MouseUp(BPoint point)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
|
|
|
UNUSED(point);
|
|
|
|
// currently a place holder function
|
2006-06-20 21:17:46 +04:00
|
|
|
BX_DEBUG(("mouseup()"));
|
2001-12-07 21:52:24 +03:00
|
|
|
BView::MouseUp(point);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2006-06-20 21:17:46 +04:00
|
|
|
void BochsView::MouseMoved(BPoint point,
|
2001-04-10 05:04:59 +04:00
|
|
|
uint32 transit, const BMessage *message)
|
|
|
|
{
|
|
|
|
UNUSED(point);
|
|
|
|
UNUSED(transit);
|
|
|
|
UNUSED(message);
|
2006-06-20 21:17:46 +04:00
|
|
|
BX_DEBUG(("mousemoved()"));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void BochsView::KeyDown(const char *bytes, int32 numBytes)
|
|
|
|
{
|
|
|
|
BMessage *msg;
|
|
|
|
//int32 key;
|
|
|
|
int32 modifiers;
|
|
|
|
|
|
|
|
uint8 byte;
|
|
|
|
|
|
|
|
msg = Window()->CurrentMessage();
|
2006-06-20 21:17:46 +04:00
|
|
|
if (!msg) {
|
|
|
|
BX_DEBUG(("keydown() msg NULL"));
|
2001-04-10 05:04:59 +04:00
|
|
|
return;
|
2006-06-20 21:17:46 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
modifiers = msg->FindInt32("modifiers");
|
|
|
|
#if 0
|
|
|
|
B_SHIFT_KEY = 0x00000001,
|
|
|
|
B_COMMAND_KEY = 0x00000002,
|
|
|
|
B_CONTROL_KEY = 0x00000004,
|
|
|
|
B_CAPS_LOCK = 0x00000008,
|
|
|
|
B_SCROLL_LOCK = 0x00000010,
|
|
|
|
B_NUM_LOCK = 0x00000020,
|
|
|
|
B_OPTION_KEY = 0x00000040,
|
|
|
|
B_MENU_KEY = 0x00000080,
|
|
|
|
B_LEFT_SHIFT_KEY = 0x00000100,
|
|
|
|
B_RIGHT_SHIFT_KEY = 0x00000200,
|
|
|
|
B_LEFT_COMMAND_KEY = 0x00000400,
|
|
|
|
B_RIGHT_COMMAND_KEY = 0x00000800,
|
|
|
|
B_LEFT_CONTROL_KEY = 0x00001000,
|
|
|
|
B_RIGHT_CONTROL_KEY = 0x00002000,
|
|
|
|
B_LEFT_OPTION_KEY = 0x00004000,
|
|
|
|
B_RIGHT_OPTION_KEY = 0x00008000
|
|
|
|
#endif
|
|
|
|
//if (modifiers) {
|
|
|
|
// fprintf(stderr, "# modifiers = %08x\n", (unsigned) modifiers);
|
2006-06-20 21:17:46 +04:00
|
|
|
//}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
if (numBytes == 1) {
|
|
|
|
//fprintf(stderr, "# down: char %02xh\n", (unsigned) bytes[0]);
|
|
|
|
byte = bytes[0];
|
2006-06-20 21:17:46 +04:00
|
|
|
if (byte == 0x00) {
|
2001-04-10 05:04:59 +04:00
|
|
|
// Ctrl-Space
|
|
|
|
enq_key_event(BX_KEY_CTRL_L, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_SPACE, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_SPACE, BX_KEY_RELEASED);
|
|
|
|
enq_key_event(BX_KEY_CTRL_L, BX_KEY_RELEASED);
|
|
|
|
return;
|
2006-06-20 21:17:46 +04:00
|
|
|
}
|
|
|
|
if (byte == 0x1b) {
|
2001-04-10 05:04:59 +04:00
|
|
|
// Esc
|
|
|
|
if (modifiers & B_CONTROL_KEY)
|
|
|
|
enq_key_event(BX_KEY_CTRL_L, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_ESC, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_ESC, BX_KEY_RELEASED);
|
|
|
|
if (modifiers & B_CONTROL_KEY)
|
|
|
|
enq_key_event(BX_KEY_CTRL_L, BX_KEY_RELEASED);
|
|
|
|
return;
|
2006-06-20 21:17:46 +04:00
|
|
|
}
|
|
|
|
if ((byte >= 0x30) && (byte <= 0x39)) {
|
2001-04-10 05:04:59 +04:00
|
|
|
// 0 .. 9
|
|
|
|
byte -= 0x30;
|
|
|
|
enq_key_event(BX_KEY_0 + byte, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_0 + byte, BX_KEY_RELEASED);
|
|
|
|
return;
|
2006-06-20 21:17:46 +04:00
|
|
|
}
|
|
|
|
if ((byte >= 0x41) && (byte <= 0x5A)) {
|
2001-04-10 05:04:59 +04:00
|
|
|
// A .. Z
|
|
|
|
byte -= 0x41;
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_A + byte, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_A + byte, BX_KEY_RELEASED);
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED);
|
|
|
|
return;
|
2006-06-20 21:17:46 +04:00
|
|
|
}
|
|
|
|
if ((byte >= 0x61) && (byte <= 0x7A)) {
|
2001-04-10 05:04:59 +04:00
|
|
|
// a .. z
|
|
|
|
byte -= 0x61;
|
|
|
|
enq_key_event(BX_KEY_A + byte, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_A + byte, BX_KEY_RELEASED);
|
|
|
|
return;
|
2006-06-20 21:17:46 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
switch (byte) {
|
|
|
|
case 0x20: // Space
|
|
|
|
enq_key_event(BX_KEY_SPACE, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_SPACE, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case 0x21: // Exclamation Point
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_1, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_1, BX_KEY_RELEASED);
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case 0x22: // Double Quotes
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_SINGLE_QUOTE, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_SINGLE_QUOTE, BX_KEY_RELEASED);
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case 0x23: // Pound Sign
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_3, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_3, BX_KEY_RELEASED);
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case 0x24: // Dollar Sign
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_4, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_4, BX_KEY_RELEASED);
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case 0x25: // Percent
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_5, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_5, BX_KEY_RELEASED);
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case 0x26: // Ampersand
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_7, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_7, BX_KEY_RELEASED);
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case 0x27: // Single Quote
|
|
|
|
enq_key_event(BX_KEY_SINGLE_QUOTE, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_SINGLE_QUOTE, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case 0x28: // Left Paren
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_9, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_9, BX_KEY_RELEASED);
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case 0x29: // Right Paren
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_0, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_0, BX_KEY_RELEASED);
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case 0x2a: // Multiply
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_8, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_8, BX_KEY_RELEASED);
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case 0x2b: // Add
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_EQUALS, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_EQUALS, BX_KEY_RELEASED);
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case 0x2c: // Comma
|
|
|
|
enq_key_event(BX_KEY_COMMA, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_COMMA, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case 0x2d: // Minus
|
|
|
|
enq_key_event(BX_KEY_MINUS, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_MINUS, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case 0x2e: // Period
|
|
|
|
enq_key_event(BX_KEY_PERIOD, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_PERIOD, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case 0x2f: // Slash
|
|
|
|
enq_key_event(BX_KEY_SLASH, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_SLASH, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x3a: // Colon
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_SEMICOLON, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_SEMICOLON, BX_KEY_RELEASED);
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case 0x3b: // Semi-Colon
|
|
|
|
enq_key_event(BX_KEY_SEMICOLON, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_SEMICOLON, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case 0x3c: // Less Than
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_COMMA, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_COMMA, BX_KEY_RELEASED);
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case 0x3d: // Equals
|
|
|
|
enq_key_event(BX_KEY_EQUALS, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_EQUALS, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case 0x3e: // Greater Than
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_PERIOD, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_PERIOD, BX_KEY_RELEASED);
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case 0x3f: // Question Mark
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_SLASH, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_SLASH, BX_KEY_RELEASED);
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case 0x40: // At Sign
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_2, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_2, BX_KEY_RELEASED);
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x5b: // Left Bracket
|
|
|
|
enq_key_event(BX_KEY_LEFT_BRACKET, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_LEFT_BRACKET, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case 0x5c: // Back Slash
|
|
|
|
enq_key_event(BX_KEY_BACKSLASH, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_BACKSLASH, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case 0x5d: // Right Bracket
|
|
|
|
enq_key_event(BX_KEY_RIGHT_BRACKET, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_RIGHT_BRACKET, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case 0x5e: // Caret
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_6, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_6, BX_KEY_RELEASED);
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case 0x5f: // Underscore
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_MINUS, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_MINUS, BX_KEY_RELEASED);
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case 0x60: // Grave Accent
|
|
|
|
enq_key_event(BX_KEY_GRAVE, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_GRAVE, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x7b: // Left Brace
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_LEFT_BRACKET, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_LEFT_BRACKET, BX_KEY_RELEASED);
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case 0x7c: // Verticle Bar
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_BACKSLASH, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_BACKSLASH, BX_KEY_RELEASED);
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case 0x7d: // Right Brace
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_RIGHT_BRACKET, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_RIGHT_BRACKET, BX_KEY_RELEASED);
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case 0x7e: // Tilde
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_GRAVE, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_GRAVE, BX_KEY_RELEASED);
|
|
|
|
enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case B_BACKSPACE:
|
|
|
|
enq_key_event(BX_KEY_BACKSPACE, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_BACKSPACE, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case B_ENTER: //case B_RETURN:
|
|
|
|
enq_key_event(BX_KEY_ENTER, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_ENTER, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case B_TAB:
|
|
|
|
enq_key_event(BX_KEY_TAB, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_TAB, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case B_LEFT_ARROW:
|
|
|
|
enq_key_event(BX_KEY_LEFT, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_LEFT, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case B_RIGHT_ARROW:
|
|
|
|
enq_key_event(BX_KEY_RIGHT, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_RIGHT, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case B_UP_ARROW:
|
|
|
|
enq_key_event(BX_KEY_UP, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_UP, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case B_DOWN_ARROW:
|
|
|
|
enq_key_event(BX_KEY_DOWN, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_DOWN, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
#if 0
|
|
|
|
case B_FUNCTION_KEY: break;
|
|
|
|
msg->FindInt32("key", &key);
|
2008-02-16 01:05:43 +03:00
|
|
|
switch (key) {
|
2001-04-10 05:04:59 +04:00
|
|
|
case B_F1_KEY: break;
|
|
|
|
case B_F2_KEY: break;
|
|
|
|
case B_F3_KEY: break;
|
|
|
|
case B_F4_KEY: break;
|
|
|
|
case B_F5_KEY: break;
|
|
|
|
case B_F6_KEY: break;
|
|
|
|
case B_F7_KEY: break;
|
|
|
|
case B_F8_KEY: break;
|
|
|
|
case B_F9_KEY: break;
|
|
|
|
case B_F10_KEY: break;
|
|
|
|
case B_F11_KEY: break;
|
|
|
|
case B_F12_KEY: break;
|
|
|
|
case B_PRINT_KEY: break;
|
|
|
|
case B_SCROLL_KEY: break;
|
|
|
|
case B_PAUSE_KEY: break;
|
|
|
|
default:
|
|
|
|
fprintf(stderr, "# keydown() unknown function key %08xh\n",
|
|
|
|
(unsigned) key);
|
2006-06-20 21:17:46 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
#endif
|
|
|
|
case B_INSERT: break;
|
|
|
|
enq_key_event(BX_KEY_INSERT, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_INSERT, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case B_DELETE: break;
|
|
|
|
enq_key_event(BX_KEY_DELETE, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_DELETE, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case B_HOME: break;
|
|
|
|
enq_key_event(BX_KEY_HOME, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_HOME, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case B_END: break;
|
|
|
|
enq_key_event(BX_KEY_END, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_END, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case B_PAGE_UP: break;
|
|
|
|
enq_key_event(BX_KEY_PAGE_UP, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_PAGE_UP, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
case B_PAGE_DOWN: break;
|
|
|
|
enq_key_event(BX_KEY_PAGE_DOWN, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_PAGE_DOWN, BX_KEY_RELEASED);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2008-02-16 01:05:43 +03:00
|
|
|
if ((byte >= 0x01) && (byte <= 0x1a)) {
|
2001-04-10 05:04:59 +04:00
|
|
|
// If the above keys dont catch this case, synthesize a
|
|
|
|
// Ctrl-A .. Ctrl-Z event
|
|
|
|
byte -= 1;
|
|
|
|
enq_key_event(BX_KEY_CTRL_L, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_A + byte, BX_KEY_PRESSED);
|
|
|
|
enq_key_event(BX_KEY_A + byte, BX_KEY_RELEASED);
|
|
|
|
enq_key_event(BX_KEY_CTRL_L, BX_KEY_RELEASED);
|
|
|
|
return;
|
2006-06-20 21:17:46 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
fprintf(stderr, "# keydown: char %02xh unhandled\n",
|
|
|
|
(unsigned) bytes[0]);
|
|
|
|
return;
|
|
|
|
}
|
2006-06-20 21:17:46 +04:00
|
|
|
return;
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
else {
|
|
|
|
// ignore for now
|
|
|
|
fprintf(stderr, "# keydown() ignoring multibyte key\n");
|
2006-06-20 21:17:46 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void BochsView::KeyUp(const char *bytes, int32 numBytes)
|
|
|
|
{
|
|
|
|
UNUSED(bytes);
|
|
|
|
UNUSED(numBytes);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BochsView::Draw(BRect rect)
|
|
|
|
{
|
2006-06-20 21:17:46 +04:00
|
|
|
DrawBitmapAsync(backing_store, rect, rect);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
BochsView::~BochsView()
|
|
|
|
{
|
2006-06-20 21:17:46 +04:00
|
|
|
delete backing_store;
|
|
|
|
delete backing_view;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2006-06-20 21:17:46 +04:00
|
|
|
void BochsView::SetFont(const BFont *font, uint32 mask)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2006-06-20 21:17:46 +04:00
|
|
|
backing_store->Lock();
|
|
|
|
backing_view->SetFont(font,mask);
|
|
|
|
backing_store->Unlock();
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2006-06-20 21:17:46 +04:00
|
|
|
void BochsView::SetHighColor(uchar r, uchar g, uchar b, uchar a)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2006-06-20 21:17:46 +04:00
|
|
|
backing_store->Lock();
|
|
|
|
backing_view->SetHighColor(r,g,b,a);
|
|
|
|
backing_store->Unlock();
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2006-06-20 21:17:46 +04:00
|
|
|
void BochsView::SetLowColor(uchar r, uchar g, uchar b, uchar a)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2006-06-20 21:17:46 +04:00
|
|
|
backing_store->Lock();
|
|
|
|
backing_view->SetLowColor(r,g,b,a);
|
|
|
|
backing_store->Unlock();
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2006-06-20 21:17:46 +04:00
|
|
|
void BochsView::DrawBitmap(const BBitmap *aBitmap, BPoint where)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2006-06-20 21:17:46 +04:00
|
|
|
backing_store->Lock();
|
|
|
|
backing_view->DrawBitmap(aBitmap,where);
|
|
|
|
backing_store->Unlock();
|
|
|
|
BRect r = aBitmap->Bounds();
|
|
|
|
r.OffsetBy(where);
|
|
|
|
Invalidate(r);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2006-06-20 21:17:46 +04:00
|
|
|
void BochsView::FillRect(BRect r, pattern p)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2006-06-20 21:17:46 +04:00
|
|
|
backing_store->Lock();
|
|
|
|
backing_view->FillRect(r,p);
|
|
|
|
backing_store->Unlock();
|
|
|
|
Invalidate(r);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2006-06-20 21:17:46 +04:00
|
|
|
void enq_key_event(Bit32u key, Bit32u press_release)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2006-06-20 21:17:46 +04:00
|
|
|
if (((tail+1) % SCANCODE_BUFSIZE) == head) {
|
2001-04-10 05:04:59 +04:00
|
|
|
fprintf(stderr, "# enq_key_event: buffer full\n");
|
|
|
|
return;
|
2006-06-20 21:17:46 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
keyevents[tail] = key | press_release;
|
|
|
|
tail = (tail + 1) % SCANCODE_BUFSIZE;
|
|
|
|
}
|
|
|
|
|
2006-06-20 21:17:46 +04:00
|
|
|
Bit32u deq_key_event(void)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
|
|
|
Bit32u key;
|
|
|
|
|
2006-06-20 21:17:46 +04:00
|
|
|
if (head == tail) {
|
2001-04-10 05:04:59 +04:00
|
|
|
fprintf(stderr, "# deq_key_event: buffer empty\n");
|
|
|
|
return(0);
|
2006-06-20 21:17:46 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
key = keyevents[head];
|
|
|
|
head = (head + 1) % SCANCODE_BUFSIZE;
|
|
|
|
return(key);
|
|
|
|
}
|
|
|
|
|
2006-06-20 21:17:46 +04:00
|
|
|
unsigned char reverse_bitorder(unsigned char b)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
|
|
|
unsigned char ret=0;
|
|
|
|
for (unsigned i=0; i<8; i++) {
|
|
|
|
ret |= (b & 0x01) << (7-i);
|
|
|
|
b >>= 1;
|
2006-06-20 21:17:46 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
return(ret);
|
|
|
|
}
|
|
|
|
|
2006-06-20 21:17:46 +04:00
|
|
|
unsigned bx_beos_gui_c::create_bitmap(const unsigned char *bmap,
|
2001-04-10 05:04:59 +04:00
|
|
|
unsigned xdim, unsigned ydim)
|
|
|
|
{
|
|
|
|
BRect rect(0.0, 0.0, xdim-1, ydim-1);
|
|
|
|
int32 bitslength;
|
|
|
|
//int32 bytesperrow;
|
|
|
|
unsigned char *data;
|
|
|
|
|
|
|
|
if (bx_bitmap_entries >= BX_MAX_PIXMAPS) {
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("beos: too many pixmaps, increase BX_MAX_PIXMAPS"));
|
2006-06-20 21:17:46 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
bx_bitmaps[bx_bitmap_entries].bmap =
|
|
|
|
new BBitmap(rect, B_MONOCHROME_1_BIT);
|
|
|
|
|
|
|
|
bitslength = bx_bitmaps[bx_bitmap_entries].bmap->BitsLength();
|
|
|
|
//bytesperrow = bx_bitmaps[bx_bitmap_entries].bmap->BytesPerRow();
|
|
|
|
data = (unsigned char *) bx_bitmaps[bx_bitmap_entries].bmap->Bits();
|
|
|
|
for (int32 i=0; i<bitslength; i++) {
|
|
|
|
data[i] = reverse_bitorder(bmap[i]);
|
2006-06-20 21:17:46 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
bx_bitmaps[bx_bitmap_entries].xdim = xdim;
|
|
|
|
bx_bitmaps[bx_bitmap_entries].ydim = ydim;
|
|
|
|
if (!bx_bitmaps[bx_bitmap_entries].bmap) {
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("beos: could not create bitmap"));
|
2006-06-20 21:17:46 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
bx_bitmap_entries++;
|
|
|
|
return(bx_bitmap_entries-1); // return index as handle
|
|
|
|
}
|
|
|
|
|
2006-06-20 21:17:46 +04:00
|
|
|
unsigned bx_beos_gui_c::headerbar_bitmap(unsigned bmap_id, unsigned alignment,
|
2001-04-10 05:04:59 +04:00
|
|
|
void (*f)(void))
|
|
|
|
{
|
|
|
|
unsigned hb_index;
|
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
if ((bx_headerbar_entries+1) > BX_MAX_HEADERBAR_ENTRIES)
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("beos: too many headerbar entries, increase BX_MAX_HEADERBAR_ENTRIES"));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
bx_headerbar_entries++;
|
|
|
|
hb_index = bx_headerbar_entries - 1;
|
|
|
|
|
|
|
|
bx_headerbar_entry[hb_index].bitmap = bx_bitmaps[bmap_id].bmap;
|
|
|
|
bx_headerbar_entry[hb_index].xdim = bx_bitmaps[bmap_id].xdim;
|
|
|
|
bx_headerbar_entry[hb_index].ydim = bx_bitmaps[bmap_id].ydim;
|
|
|
|
bx_headerbar_entry[hb_index].alignment = alignment;
|
|
|
|
bx_headerbar_entry[hb_index].f = f;
|
|
|
|
if (alignment == BX_GRAVITY_LEFT) {
|
|
|
|
bx_headerbar_entry[hb_index].xorigin = bx_bitmap_left_xorigin;
|
|
|
|
bx_headerbar_entry[hb_index].yorigin = 0;
|
|
|
|
bx_bitmap_left_xorigin += bx_bitmaps[bmap_id].xdim;
|
2006-06-20 21:17:46 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
else { // BX_GRAVITY_RIGHT
|
|
|
|
bx_bitmap_right_xorigin += bx_bitmaps[bmap_id].xdim;
|
|
|
|
bx_headerbar_entry[hb_index].xorigin = bx_bitmap_right_xorigin;
|
|
|
|
bx_headerbar_entry[hb_index].yorigin = 0;
|
2006-06-20 21:17:46 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
return(hb_index);
|
|
|
|
}
|
|
|
|
|
2006-06-20 21:17:46 +04:00
|
|
|
void bx_beos_gui_c::replace_bitmap(unsigned hbar_id, unsigned bmap_id)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
|
|
|
unsigned xorigin;
|
|
|
|
|
|
|
|
bx_headerbar_entry[hbar_id].bitmap = bx_bitmaps[bmap_id].bmap;
|
|
|
|
|
|
|
|
if (bx_headerbar_entry[hbar_id].alignment == BX_GRAVITY_LEFT)
|
|
|
|
xorigin = bx_headerbar_entry[hbar_id].xorigin;
|
|
|
|
else
|
|
|
|
xorigin = dimension_x - bx_headerbar_entry[hbar_id].xorigin;
|
|
|
|
aWindow->Lock();
|
|
|
|
aView->set_headerbar_colors();
|
|
|
|
aView->DrawBitmap(bx_headerbar_entry[hbar_id].bitmap, BPoint(xorigin, 0));
|
|
|
|
aView->set_text_colors();
|
|
|
|
aWindow->Unlock();
|
|
|
|
}
|
|
|
|
|
2006-06-20 21:17:46 +04:00
|
|
|
void bx_beos_gui_c::show_headerbar(void)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
|
|
|
unsigned xorigin;
|
|
|
|
BPoint origin;
|
|
|
|
|
|
|
|
// clear header bar area to white
|
|
|
|
|
|
|
|
aWindow->Lock();
|
|
|
|
aView->set_headerbar_colors();
|
|
|
|
aView->FillRect(BRect(0, 0, dimension_x-1, bx_headerbar_y-1), B_SOLID_LOW);
|
|
|
|
for (unsigned i=0; i<bx_headerbar_entries; i++) {
|
|
|
|
if (bx_headerbar_entry[i].alignment == BX_GRAVITY_LEFT)
|
|
|
|
xorigin = bx_headerbar_entry[i].xorigin;
|
|
|
|
else
|
|
|
|
xorigin = dimension_x - bx_headerbar_entry[i].xorigin;
|
|
|
|
origin.Set(xorigin, 0);
|
2008-02-16 01:05:43 +03:00
|
|
|
aView->DrawBitmap(bx_headerbar_entry[i].bitmap, origin);
|
2006-06-20 21:17:46 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
aView->set_text_colors();
|
|
|
|
aWindow->Unlock();
|
|
|
|
}
|
|
|
|
|
2006-06-20 21:17:46 +04:00
|
|
|
void headerbar_click(int x, int y)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
|
|
|
int xorigin;
|
|
|
|
|
|
|
|
// assuming y is in bounds
|
|
|
|
UNUSED(y);
|
|
|
|
for (unsigned i=0; i<bx_headerbar_entries; i++) {
|
|
|
|
if (bx_headerbar_entry[i].alignment == BX_GRAVITY_LEFT)
|
|
|
|
xorigin = bx_headerbar_entry[i].xorigin;
|
|
|
|
else
|
|
|
|
xorigin = dimension_x - bx_headerbar_entry[i].xorigin;
|
2008-02-16 01:05:43 +03:00
|
|
|
if ((x>=xorigin) && (x<(xorigin+int(bx_headerbar_entry[i].xdim)))) {
|
2001-04-10 05:04:59 +04:00
|
|
|
bx_headerbar_entry[i].f();
|
|
|
|
return;
|
|
|
|
}
|
2006-06-20 21:17:46 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2006-06-20 21:17:46 +04:00
|
|
|
void create_vga_font(void)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
|
|
|
int32 bitslength;
|
|
|
|
int32 bytesperrow;
|
|
|
|
unsigned char *data;
|
|
|
|
BRect brect(0,0, 7,15);
|
|
|
|
|
2008-02-16 01:05:43 +03:00
|
|
|
BX_INFO(("BeOS: creating VGA font from bitmaps"));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
// VGA font is 8wide x 16high
|
|
|
|
for (unsigned c=0; c<256; c++) {
|
|
|
|
vgafont[c] = new BBitmap(brect, B_MONOCHROME_1_BIT);
|
|
|
|
if (!vgafont[c]) {
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("beos: could not create bitmap"));
|
2006-06-20 21:17:46 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
bitslength = vgafont[c]->BitsLength();
|
|
|
|
bytesperrow = vgafont[c]->BytesPerRow();
|
|
|
|
data = (unsigned char *) vgafont[c]->Bits();
|
|
|
|
memset(data, 0, bitslength);
|
|
|
|
for (unsigned i=0; i<16; i++) {
|
|
|
|
data[i*bytesperrow] = reverse_bitorder(bx_vgafont[c].data[i]);
|
|
|
|
}
|
2006-06-20 21:17:46 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
2006-06-20 21:17:46 +04:00
|
|
|
void bx_beos_gui_c::exit(void)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2002-10-25 01:07:56 +04:00
|
|
|
fprintf(stderr, "# WARNING: BEOS: bx_beos_gui_c::exit() not implemented yet.\n");
|
2001-06-23 07:18:14 +04:00
|
|
|
}
|
|
|
|
|
2001-12-07 21:52:24 +03:00
|
|
|
//IRA=> Start
|
|
|
|
// This is called whenever the mouse_enabled parameter changes. It
|
|
|
|
// can change because of a gui event such as clicking on the mouse-enable
|
- I've added lots of comments in siminterface.h, and tried to clean up
the terminology a bit. In particular, the term "gui" has started
to mean different things in different contexts, so I've defined
some more specific names for the parts of the user interface, and
updated comments and some variable names to reflect it. See
siminterface.h for a more complete description of all of these.
VGAW: VGA display window and toolbar buttons, the traditional Bochs
display which is ported to X, win32, MacOS X, etc. Implemented
in gui/gui.* and platform dependent gui/*.cc files.
CI: configuration interface that lets the user change settings such
as floppy disk image, ne2k settings, log options. The CI consists
of two parts: configuration user interface (CUI) which does the
actual rendering to the screen and handles key/mouse/menu events,
and the siminterface object.
CUI: configuration user interface. This handles the user interactions
that allow the user to configure Bochs. To actually change any
values it talks to the siminterface object. One implementation of
the CUI is the text-mode menus in gui/control.cc. Another
implementation is (will be) the wxWindows menus and dialogs in
gui/wxmain.cc.
siminterface: the glue between the CUI and the simulation code,
accessible throughout the code by the global variable
bx_simulator_interface_c *SIM;
Among other things, siminterface methods allow the simulator to ask the
CUI to display things or ask for user input, and allows the CUI
to query and modify variables in the simulation code.
GUI: Literally, "graphical user interface". Until the configuration menus
and wxWindows came along, everyone understood that "gui" referred to the
VGA display window and the toolbar buttons because that's all there
was. Now that we have the wxWindows code, which implements both the VGAW
and the CUI, while all other platforms implement only the VGAW, it's not
so clear. So, I'm trying to use VGAW, CI, and CUI consistently since
they are more specific.
control panel: This has been used as another name for the configuration
interface. "control panel" is also somewhat unspecific and it sounds
like it would be graphical with buttons and sliders, but our text-mode
thing is not graphical at all. I've replaced "control panel" with
"configuration interface" wherever I could find it. In configure script,
the --disable-control-panel option is still supported, but it politely
suggests that you use --disable-config-interface instead.
- clean up comments in siminterface,wx* code
- add comments and examples for bx_param_* and BxEvents
- remove some obsolete stuff: notify_*_args,
bx_simulator_interface_c::[sg]et_enabled() methods
- in siminterface.cc, move a few bx_real_sim_c methods to where they belong,
with the rest of the methods. No changes to the actual methods.
- remove some DOS ^M's which crept in and confused my editor.
2002-08-26 19:31:23 +04:00
|
|
|
// bitmap or pressing the middle button, or from the configuration interface.
|
2001-12-07 21:52:24 +03:00
|
|
|
// In all those cases, setting the parameter value will get you here.
|
|
|
|
|
2006-06-20 21:17:46 +04:00
|
|
|
void bx_beos_gui_c::mouse_enabled_changed_specific (bx_bool val)
|
2001-06-23 07:18:14 +04:00
|
|
|
{
|
2001-12-07 21:52:24 +03:00
|
|
|
BX_DEBUG (("mouse_enabled=%d, BeOS specific code", val?1:0));
|
|
|
|
if (val) {
|
|
|
|
BX_INFO(("[x] Mouse on"));
|
|
|
|
// mouse_enable_x = current_x;
|
|
|
|
// mouse_enable_y = current_y;
|
|
|
|
be_app->HideCursor();
|
|
|
|
// Move the cursor to a 'safe' place
|
|
|
|
// warp_cursor(warp_home_x-current_x, warp_home_y-current_y);
|
|
|
|
} else {
|
|
|
|
BX_INFO(("[x] Mouse off"));
|
|
|
|
be_app->ShowCursor();
|
|
|
|
// warp_cursor(mouse_enable_x-current_x, mouse_enable_y-current_y);
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
2001-12-07 21:52:24 +03:00
|
|
|
//IRA=> End
|
2002-11-19 08:47:45 +03:00
|
|
|
|
|
|
|
#endif /* if BX_WITH_BEOS */
|