diff --git a/client/src/gui/gui.c b/client/src/gui/gui.c index 7e95866..3fb21a6 100644 --- a/client/src/gui/gui.c +++ b/client/src/gui/gui.c @@ -63,8 +63,39 @@ void guiModesShow(void) { void guiRun(void) { + char text[256] = { 0 }; + GrMouseEvent event; + +#define APPEND (&text[strlen(text)]) + while (_guiRunning) { + GrMouseGetEvent(GR_M_EVENT, &event); + if (event.flags != 0) { + strcpy(text, "Events: "); + if(event.flags & GR_M_MOTION) strcpy( APPEND,"[moved] "); + if(event.flags & GR_M_LEFT_DOWN) strcpy( APPEND,"[left down] "); + if(event.flags & GR_M_MIDDLE_DOWN) strcpy( APPEND,"[middle down] "); + if(event.flags & GR_M_RIGHT_DOWN) strcpy( APPEND,"[right down] "); + if(event.flags & GR_M_P4_DOWN) strcpy( APPEND,"[p4 down] "); + if(event.flags & GR_M_P5_DOWN) strcpy( APPEND,"[p5 down] "); + if(event.flags & GR_M_LEFT_UP) strcpy( APPEND,"[left up] "); + if(event.flags & GR_M_MIDDLE_UP) strcpy( APPEND,"[middle up] "); + if(event.flags & GR_M_RIGHT_UP) strcpy( APPEND,"[right up] "); + if(event.flags & GR_M_P4_UP) strcpy( APPEND,"[p4 up] "); + if(event.flags & GR_M_P5_UP) strcpy( APPEND,"[p5 up] "); + if(event.flags & GR_M_KEYPRESS) sprintf(APPEND,"[key (0x%03x)] ",event.key); + sprintf(APPEND,"at X=%d, Y=%d, ",event.x,event.y); + sprintf(APPEND, + "buttons=%c%c%c, ", + (event.buttons & GR_M_LEFT) ? 'L' : 'l', + (event.buttons & GR_M_MIDDLE) ? 'M' : 'm', + (event.buttons & GR_M_RIGHT) ? 'R' : 'r' + ); + sprintf(APPEND,"deltaT=%ld (ms)",event.dtime); + strcpy (APPEND," "); + } wmPaint(); + GrTextXY(0, 0, text, GUI_WHITE, GUI_BLACK); if (GrKeyRead() == GrKey_Escape) guiStop(); } } @@ -78,14 +109,17 @@ void guiRegister(WidgetRegisterT widgetRegister) { void guiShutdown(void) { - wmShutdown(); - while (hmlen(_widgetCatalog) > 0) { if (_widgetCatalog[0].value->unregister) _widgetCatalog[0].value->unregister(NULL); hmdel(_widgetCatalog, _widgetCatalog[0].key); } hmfree(_widgetCatalog); + wmShutdown(); + + GrMouseEraseCursor(); + GrMouseUnInit(); + DEL(__guiBaseColors); GrSetMode(GR_default_text); @@ -96,10 +130,15 @@ void guiStartup(int16_t width, int16_t height, int16_t depth) { if (!GrSetMode(GR_width_height_bpp_graphics, width, height, depth)) { //***TODO*** Die } - GrSetRGBcolorMode(); __guiBaseColors = GrAllocEgaColors(); + GrMouseInit(); + GrMouseEventEnable(1, 1); + GrMouseSetColors(GUI_WHITE, GUI_BLACK); + GrMouseSetCursorMode(GR_M_CUR_NORMAL); + GrMouseDisplayCursor(); + wmStartup(); guiRegister(windowRegister); diff --git a/client/src/gui/wmwindow.c b/client/src/gui/wmwindow.c index 0202eb3..9a5f550 100644 --- a/client/src/gui/wmwindow.c +++ b/client/src/gui/wmwindow.c @@ -4,7 +4,9 @@ uint8_t __MAGIC_WINDOW = 0; -static WindowT **_windowList = NULL; +static WindowT **_windowList = NULL; +static GrContext *_backBuffer = NULL; +static GrContext *_screenBuffer = NULL; static GrTextOption _textOption; @@ -237,14 +239,18 @@ void wmPaint(void) { WidgetT *widget; // Paint desktop. - GrClearScreen(GUI_CYAN); + GrSetContext(_backBuffer); + GrClearContext(GUI_CYAN); // Paint all windows. for (i=0; ireg->paint(widget); } + + // Copy to screen. + GrBitBltNC(_screenBuffer, 0, 0, _backBuffer, 0, 0, GrMaxX(), GrMaxY(), GrWRITE); } @@ -253,9 +259,12 @@ void wmShutdown(void) { windowDestroy((WidgetT *)_windowList[0]); } arrfree(_windowList); + + GrDestroyContext(_backBuffer); } void wmStartup(void) { - + _screenBuffer = GrScreenContext(); + _backBuffer = GrCreateContext(GrScreenX(), GrScreenY(), NULL, NULL); } diff --git a/client/src/main.c b/client/src/main.c index 444a0ac..ca95020 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -3,13 +3,19 @@ int main(int argc, char *argv[]) { + char title[256]; + uint16_t i; (void)argc; (void)argv; guiStartup(800, 600, 24); - windowCreate(50, 50, 300, 200, "Testing", WIN_CLOSE | WIN_MAXIMIZE | WIN_MINIMIZE | WIN_RESIZE); + for (i=1; i<4; i++) { + sprintf(title, "Testing %d", i); + windowCreate(i * 50, i * 50, 300, 200, title, WIN_CLOSE | WIN_MAXIMIZE | WIN_MINIMIZE | WIN_RESIZE); + } + guiRun(); guiShutdown();