# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1036603684 0 # Node ID a371875d5486632365981552c46c5119f3d51110 # Parent e780277685484e1edabf89ba58d1add9a5bd3cb4 Sync up with the latest F/X sources. diff -r e78027768548 -r a371875d5486 gtk/dw.c --- a/gtk/dw.c Wed Oct 30 12:19:26 2002 +0000 +++ b/gtk/dw.c Wed Nov 06 17:28:04 2002 +0000 @@ -6783,7 +6783,6 @@ return ret; } -#ifndef NO_SIGNALS /* * Add a callback to a window event. * Parameters: @@ -6949,156 +6948,4 @@ { dw_signal_disconnect_by_data(window, data); } -#endif - -#ifdef TEST -HWND mainwindow, - listbox, - okbutton, - cancelbutton, - lbbox, - stext, - buttonbox, - testwindow, - testbox, - testok, - testcancel, - testbox2, - testok2, - testcancel2, - notebook; -int count = 2; - -int test_callback(HWND window, void *data) -{ - dw_window_destroy((HWND)data); - /* Return -1 to allow the default handlers to return. */ - count--; - if(!count) - exit(0); - return -1; -} - -/* - * Let's demonstrate the functionality of this library. :) - */ -int main(int argc, char *argv[]) -{ - unsigned long flStyle = DW_FCF_SYSMENU | DW_FCF_TITLEBAR | - DW_FCF_SHELLPOSITION | DW_FCF_TASKLIST | DW_FCF_DLGBORDER; - int pageid; - - dw_init(TRUE, argc, argv); - - /* Try a little server dialog. :) */ - mainwindow = dw_window_new(DW_DESKTOP, "Server", flStyle | DW_FCF_SIZEBORDER | DW_FCF_MINMAX); - - lbbox = dw_box_new(BOXVERT, 10); - - dw_box_pack_start(mainwindow, lbbox, 0, 0, TRUE, TRUE, 0); - - stext = dw_text_new("Choose a server:", 0); - - dw_window_set_style(stext, DW_DT_VCENTER, DW_DT_VCENTER); - - dw_box_pack_start(lbbox, stext, 130, 15, FALSE, FALSE, 10); - - listbox = dw_listbox_new(100L, FALSE); - - dw_box_pack_start(lbbox, listbox, 130, 200, TRUE, TRUE, 10); - - buttonbox = dw_box_new(BOXHORZ, 0); - - dw_box_pack_start(lbbox, buttonbox, 0, 0, TRUE, TRUE, 0); - - okbutton = dw_button_new("Ok", 1001L); - - dw_box_pack_start(buttonbox, okbutton, 50, 30, TRUE, TRUE, 5); - - cancelbutton = dw_button_new("Cancel", 1002L); - - dw_box_pack_start(buttonbox, cancelbutton, 50, 30, TRUE, TRUE, 5); - - /* Set some nice fonts and colors */ - dw_window_set_color(lbbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); - dw_window_set_color(buttonbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); - dw_window_set_font(stext, "9.WarpSans"); - dw_window_set_color(stext, DW_CLR_BLACK, DW_CLR_PALEGRAY); - dw_window_set_font(listbox, "9.WarpSans"); - dw_window_set_font(okbutton, "9.WarpSans"); - dw_window_set_font(cancelbutton, "9.WarpSans"); - - dw_window_show(mainwindow); - - dw_window_set_usize(mainwindow, 170, 340); - - /* Another small example */ - flStyle |= DW_FCF_MINMAX | DW_FCF_SIZEBORDER; - - testwindow = dw_window_new(DW_DESKTOP, "Wow a test dialog! :) yay!", flStyle); - - testbox = dw_box_new(BOXVERT, 0); - - dw_box_pack_start(testwindow, testbox, 0, 0, TRUE, TRUE, 0); - - notebook = dw_notebook_new(1010L, TRUE); - - dw_box_pack_start(testbox, notebook, 100, 100, TRUE, TRUE, 0); - - testbox = dw_box_new(BOXVERT, 10); - - pageid = dw_notebook_page_new(notebook, 0L, FALSE); - - dw_notebook_pack(notebook, pageid, testbox); - - dw_notebook_page_set_text(notebook, pageid, "Test page"); - dw_notebook_page_set_status_text(notebook, pageid, "Test page"); - - testok = dw_button_new("Ok", 1003L); - - dw_box_pack_start(testbox, testok, 60, 40, TRUE, TRUE, 10); - - testcancel = dw_button_new("Cancel", 1004L); - - dw_box_pack_start(testbox, testcancel, 60, 40, TRUE, TRUE, 10); - - testbox2 = dw_box_new(BOXHORZ, 0); - - dw_box_pack_start(testbox, testbox2, 0, 0, TRUE, TRUE, 0); - - testok2 = dw_button_new("Ok", 1003L); - - dw_box_pack_start(testbox2, testok2, 60, 40, TRUE, TRUE, 10); - - dw_box_pack_splitbar_start(testbox2); - - testcancel2 = dw_button_new("Cancel", 1004L); - - dw_box_pack_start(testbox2, testcancel2, 60, 40, TRUE, TRUE, 10); - - /* Set some nice fonts and colors */ - dw_window_set_color(testbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); - dw_window_set_color(testbox2, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); - dw_window_set_font(testok, "9.WarpSans"); - dw_window_set_font(testcancel, "9.WarpSans"); - dw_window_set_font(testok2, "9.WarpSans"); - dw_window_set_font(testcancel2, "9.WarpSans"); - - dw_window_show(testwindow); - - /* Setup the function callbacks */ - dw_signal_connect(okbutton, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow); - dw_signal_connect(cancelbutton, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow); - dw_signal_connect(testok, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); - dw_signal_connect(testcancel, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); - dw_signal_connect(testok2, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); - dw_signal_connect(testcancel2, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); - dw_signal_connect(mainwindow, "delete_event", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow); - dw_signal_connect(testwindow, "delete_event", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); - - dw_main(); - - return 0; -} -#endif - + diff -r e78027768548 -r a371875d5486 os2/dw.c --- a/os2/dw.c Wed Oct 30 12:19:26 2002 +0000 +++ b/os2/dw.c Wed Nov 06 17:28:04 2002 +0000 @@ -343,7 +343,31 @@ char tmpbuf[100] = ""; WinQueryClassName(box->items[z].hwnd, 99, tmpbuf); - if(strncmp(tmpbuf, "#40", 4)==0) /* Notebook */ + if(strncmp(tmpbuf, SplitbarClassName, strlen(SplitbarClassName)+1)==0) + { + /* Then try the bottom or right box */ + HWND mybox = (HWND)dw_window_get_data(box->items[z].hwnd, "_dw_bottomright"); + + if(mybox) + { + Box *splitbox = (Box *)WinQueryWindowPtr(mybox, QWP_USER); + + if(splitbox && _focus_check_box(splitbox, handle, start == 3 ? 3 : 0, defaultitem)) + return 1; + } + + /* Try the top or left box */ + mybox = (HWND)dw_window_get_data(box->items[z].hwnd, "_dw_topleft"); + + if(mybox) + { + Box *splitbox = (Box *)WinQueryWindowPtr(mybox, QWP_USER); + + if(splitbox && _focus_check_box(splitbox, handle, start == 3 ? 3 : 0, defaultitem)) + return 1; + } + } + else if(strncmp(tmpbuf, "#40", 4)==0) /* Notebook */ { Box *notebox; HWND page = (HWND)WinSendMsg(box->items[z].hwnd, BKM_QUERYPAGEWINDOWHWND, @@ -1357,27 +1381,9 @@ WinSetFocus(HWND_DESKTOP, handle); } -MRESULT EXPENTRY _comboentryproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) -{ - WindowData *blah = (WindowData *)WinQueryWindowPtr(hWnd, QWP_USER); - - switch(msg) - { - case WM_SETFOCUS: - _run_event(hWnd, msg, mp1, mp2); - break; - case WM_CHAR: - /* A Similar problem to the MLE, if ESC just return */ - if(SHORT1FROMMP(mp2) == 283) - return (MRESULT)TRUE; - break; - } - - if(blah && blah->oldproc) - return blah->oldproc(hWnd, msg, mp1, mp2); - - return WinDefWindowProc(hWnd, msg, mp1, mp2); -} +#define ENTRY_CUT 1001 +#define ENTRY_COPY 1002 +#define ENTRY_PASTE 1003 /* Originally just intended for entryfields, it now serves as a generic * procedure for handling TAB presses to change input focus on controls. @@ -1386,30 +1392,95 @@ { WindowData *blah = (WindowData *)WinQueryWindowPtr(hWnd, QWP_USER); PFNWP oldproc = 0; + char tmpbuf[100]; if(blah) oldproc = blah->oldproc; + WinQueryClassName(hWnd, 99, tmpbuf); + + /* These are the window classes which should get a menu */ + if(strncmp(tmpbuf, "#2", 3)==0 || /* Combobox */ + strncmp(tmpbuf, "#6", 3)==0 || /* Entryfield */ + strncmp(tmpbuf, "#10", 4)==0 || /* MLE */ + strncmp(tmpbuf, "#32", 4)==0) /* Spinbutton */ + { + switch(msg) + { + case WM_CONTEXTMENU: + { + HWND menuitem; + HMENUI hwndMenu = dw_menu_new(0L); + long x, y; + + menuitem = dw_menu_append_item(hwndMenu, "Copy", ENTRY_COPY, 0L, TRUE, FALSE, 0L); + if(strncmp(tmpbuf, "#10", 4)!=0 || (strncmp(tmpbuf, "#10", 4)==0 && !WinSendMsg(hWnd, MLM_QUERYREADONLY, 0, 0))) + { + menuitem = dw_menu_append_item(hwndMenu, "Cut", ENTRY_CUT, 0L, TRUE, FALSE, 0L); + menuitem = dw_menu_append_item(hwndMenu, "Paste", ENTRY_PASTE, 0L, TRUE, FALSE, 0L); + } + + dw_pointer_query_pos(&x, &y); + dw_menu_popup(&hwndMenu, hWnd, x, y); + } + break; + case WM_COMMAND: + { + ULONG command = COMMANDMSG(&msg)->cmd; + + /* MLE */ + if(strncmp(tmpbuf, "#10", 4)==0) + { + switch(command) + { + case ENTRY_CUT: + return WinSendMsg(hWnd, MLM_CUT, 0, 0); + case ENTRY_COPY: + return WinSendMsg(hWnd, MLM_COPY, 0, 0); + case ENTRY_PASTE: + return WinSendMsg(hWnd, MLM_PASTE, 0, 0); + } + } + else /* Other */ + { + HWND handle = hWnd; + + /* Get the entryfield handle from multi window controls */ + if(strncmp(tmpbuf, "#2", 3)==0) + handle = WinWindowFromID(hWnd, 667); + if(strncmp(tmpbuf, "#32", 4)==0) + handle = WinWindowFromID(hWnd, 1703); + + if(handle) + { + switch(command) + { + case ENTRY_CUT: + return WinSendMsg(handle, EM_CUT, 0, 0); + case ENTRY_COPY: + return WinSendMsg(handle, EM_COPY, 0, 0); + case ENTRY_PASTE: + return WinSendMsg(handle, EM_PASTE, 0, 0); + } + } + } + } + break; + } + } + switch(msg) { case WM_BUTTON1DOWN: case WM_BUTTON2DOWN: case WM_BUTTON3DOWN: { - char tmpbuf[100]; - - WinQueryClassName(hWnd, 99, tmpbuf); - if(strncmp(tmpbuf, "#32", 4)==0) _run_event(hWnd, WM_SETFOCUS, (MPARAM)FALSE, (MPARAM)TRUE); } break; case WM_CONTROL: { - char tmpbuf[100]; - - WinQueryClassName(hWnd, 99, tmpbuf); - if(strncmp(tmpbuf, "#38", 4)==0) _run_event(hWnd, msg, mp1, mp2); } @@ -1437,10 +1508,6 @@ break; case WM_SIZE: { - char tmpbuf[100]; - - WinQueryClassName(hWnd, 99, tmpbuf); - /* If it's a slider... make sure it shows the correct value */ if(strncmp(tmpbuf, "#38", 4)==0) WinPostMsg(hWnd, WM_USER+7, 0, 0); @@ -1460,6 +1527,49 @@ return WinDefWindowProc(hWnd, msg, mp1, mp2); } +/* Deal with combobox specifics and enhancements */ +MRESULT EXPENTRY _comboentryproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) +{ + WindowData *blah = (WindowData *)WinQueryWindowPtr(hWnd, QWP_USER); + + switch(msg) + { + case WM_CONTEXTMENU: + case WM_COMMAND: + return _entryproc(hWnd, msg, mp1, mp2); + case WM_SETFOCUS: + _run_event(hWnd, msg, mp1, mp2); + break; + case WM_CHAR: + /* A Similar problem to the MLE, if ESC just return */ + if(SHORT1FROMMP(mp2) == 283) + return (MRESULT)TRUE; + break; + } + + if(blah && blah->oldproc) + return blah->oldproc(hWnd, msg, mp1, mp2); + + return WinDefWindowProc(hWnd, msg, mp1, mp2); +} + +/* Enhance the standard OS/2 MLE control */ +MRESULT EXPENTRY _mleproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) +{ + switch(msg) + { + case WM_VSCROLL: + if(SHORT2FROMMP(mp2) == SB_SLIDERTRACK) + { + USHORT pos = SHORT1FROMMP(mp2); + + return WinSendMsg(hWnd, msg, mp1, MPFROM2SHORT(pos, SB_SLIDERPOSITION)); + } + break; + } + return _entryproc(hWnd, msg, mp1, mp2); +} + int _dw_int_pos(HWND hwnd) { int pos = (int)dw_window_get_data(hwnd, "_dw_percent_value"); @@ -3694,7 +3804,7 @@ NULL, NULL); dw_window_set_font(tmp, DefaultFont); - blah->oldproc = WinSubclassWindow(tmp, _entryproc); + blah->oldproc = WinSubclassWindow(tmp, _mleproc); WinSetWindowPtr(tmp, QWP_USER, blah); return tmp; } @@ -4741,13 +4851,8 @@ */ void dw_mle_set_visible(HWND handle, int line) { - int tmppnt; - - if(line > 10) - { - tmppnt = (int)WinSendMsg(handle, MLM_CHARFROMLINE, MPFROMLONG(line - 10), 0); - WinSendMsg(handle, MLM_SETFIRSTCHAR, MPFROMLONG(tmppnt), 0); - } + int tmppnt = (int)WinSendMsg(handle, MLM_CHARFROMLINE, MPFROMLONG(line), 0); + WinSendMsg(handle, MLM_SETSEL, MPFROMLONG(tmppnt), MPFROMLONG(tmppnt)); } /* diff -r e78027768548 -r a371875d5486 win/dw.c --- a/win/dw.c Wed Oct 30 12:19:26 2002 +0000 +++ b/win/dw.c Wed Nov 06 17:28:04 2002 +0000 @@ -51,16 +51,6 @@ HPEN _hPen[THREAD_LIMIT]; HBRUSH _hBrush[THREAD_LIMIT]; -#ifdef DWDEBUG -FILE *f; - -void reopen(void) -{ - fclose(f); - f = fopen("dw.log", "at"); -} -#endif - BYTE _red[] = { 0x00, 0xbb, 0x00, 0xaa, 0x00, 0xbb, 0x00, 0xaa, 0x77, 0xff, 0x00, 0xee, 0x00, 0xff, 0x00, 0xff, 0xaa, 0x00 }; BYTE _green[] = { 0x00, 0x00, 0xbb, 0xaa, 0x00, 0x00, 0xbb, 0xaa, 0x77, @@ -487,7 +477,31 @@ GetClassName(box->items[z].hwnd, tmpbuf, 99); - if(strnicmp(tmpbuf, WC_TABCONTROL, strlen(WC_TABCONTROL))==0) /* Notebook */ + if(strncmp(tmpbuf, SplitbarClassName, strlen(SplitbarClassName)+1)==0) + { + /* Then try the bottom or right box */ + HWND mybox = (HWND)dw_window_get_data(box->items[z].hwnd, "_dw_bottomright"); + + if(mybox) + { + Box *splitbox = (Box *)GetWindowLong(mybox, GWL_USERDATA); + + if(splitbox && _focus_check_box(splitbox, handle, start == 3 ? 3 : 0, defaultitem)) + return 1; + } + + /* Try the top or left box */ + mybox = (HWND)dw_window_get_data(box->items[z].hwnd, "_dw_topleft"); + + if(mybox) + { + Box *splitbox = (Box *)GetWindowLong(mybox, GWL_USERDATA); + + if(splitbox && _focus_check_box(splitbox, handle, start == 3 ? 3 : 0, defaultitem)) + return 1; + } + } + else if(strnicmp(tmpbuf, WC_TABCONTROL, strlen(WC_TABCONTROL))==0) /* Notebook */ { NotebookPage **array = (NotebookPage **)GetWindowLong(box->items[z].hwnd, GWL_USERDATA); int pageid = TabCtrl_GetCurSel(box->items[z].hwnd); @@ -760,14 +774,6 @@ tmp->xratio = thisbox->xratio; tmp->yratio = thisbox->yratio; -#ifdef DWDEBUG - if(pass > 1) - { - fprintf(f, "FARK! depth %d\r\nwidth = %d, height = %d, nux = %d, nuy = %d, upx = %d, upy = %d xratio = %f, yratio = %f\r\n\r\n", - *depth, thisbox->items[z].width, thisbox->items[z].height, nux, nuy, tmp->upx, tmp->upy, tmp->xratio, tmp->yratio); - reopen(); - } -#endif if(thisbox->type == BOXVERT) { if((thisbox->items[z].width-((thisbox->items[z].pad*2)+(tmp->pad*2)))!=0) @@ -795,15 +801,6 @@ (*depth)++; -#ifdef DWDEBUG - if(pass > 1) - { - fprintf(f, "Before Resize Box depth %d\r\nx = %d, y = %d, usedx = %d, usedy = %d, usedpadx = %d, usedpady = %d xratio = %f, yratio = %f\r\n\r\n", - *depth, x, y, *usedx, *usedy, *usedpadx, *usedpady, tmp->xratio, tmp->yratio); - reopen(); - } -#endif - _resize_box(tmp, depth, x, y, &nux, &nuy, pass, &upx, &upy); (*depth)--; @@ -813,15 +810,6 @@ tmp->minwidth = thisbox->items[z].width = initialx - newx; tmp->minheight = thisbox->items[z].height = initialy - newy; - -#ifdef DWDEBUG - if(pass > 1) - { - fprintf(f, "After Resize Box depth %d\r\nx = %d, y = %d, usedx = %d, usedy = %d, usedpadx = %d, usedpady = %d width = %d, height = %d\r\n\r\n", - *depth, x, y, *usedx, *usedy, *usedpadx, *usedpady, thisbox->items[z].width, thisbox->items[z].height); - reopen(); - } -#endif } } @@ -867,12 +855,6 @@ tmp->parentyratio = thisbox->items[z].yratio; } } - -#ifdef DWDEBUG - fprintf(f, "RATIO- xratio = %f, yratio = %f, width = %d, height = %d, pad = %d, box xratio = %f, box yratio = %f, parent xratio = %f, parent yratio = %f, minwidth = %d, minheight = %d, width = %d, height = %d, upx = %d, upy = %d\r\n\r\n", - thisbox->items[z].xratio, thisbox->items[z].yratio, thisbox->items[z].width, thisbox->items[z].height, thisbox->items[z].pad, thisbox->xratio, thisbox->yratio, thisbox->parentxratio, thisbox->parentyratio, thisbox->minwidth, thisbox->minheight, thisbox->width, thisbox->height, thisbox->upx, thisbox->upy); - reopen(); -#endif } else { @@ -952,12 +934,6 @@ currentx += thisbox->pad; currenty += thisbox->pad; -#ifdef DWDEBUG - fprintf(f, "Done Calc depth %d\r\nusedx = %d, usedy = %d, usedpadx = %d, usedpady = %d, currentx = %d, currenty = %d, uxmax = %d, uymax = %d\r\n\r\n", - *depth, *usedx, *usedy, *usedpadx, *usedpady, currentx, currenty, uxmax, uymax); - reopen(); -#endif - /* The second pass is for expansion and actual placement. */ if(pass > 1) { @@ -991,12 +967,6 @@ (*depth)++; -#ifdef DWDEBUG - fprintf(f, "2- Resize Box depth %d\r\nx = %d, y = %d, usedx = %d, usedy = %d, usedpadx = %d, usedpady = %d xratio = %f, yratio = %f,\r\nupx = %d, upy = %d, width = %d, height = %d, minwidth = %d, minheight = %d, box xratio = %f, box yratio = %f\r\n\r\n", - *depth, x, y, *usedx, *usedy, *usedpadx, *usedpady, tmp->xratio, tmp->yratio, tmp->upx, tmp->upy, thisbox->items[z].width, thisbox->items[z].height, tmp->minwidth, tmp->minheight, thisbox->xratio, thisbox->yratio); - reopen(); -#endif - _resize_box(tmp, depth, x, y, &nux, &nuy, 3, &nupx, &nupy); (*depth)--; @@ -1114,12 +1084,6 @@ } } -#ifdef DWDEBUG - fprintf(f, "Window Pos depth %d\r\ncurrentx = %d, currenty = %d, pad = %d, width = %d, height = %d, vectorx = %d, vectory = %d, Box type = %s\r\n\r\n", - *depth, currentx, currenty, pad, width, height, vectorx, vectory,thisbox->type == BOXHORZ ? "Horizontal" : "Vertical"); - reopen(); -#endif - if(thisbox->type == BOXHORZ) currentx += width + vectorx + (pad * 2); if(thisbox->type == BOXVERT) @@ -1146,21 +1110,9 @@ thisbox->xratio = ((float)(x-usedpadx))/((float)(usedx-usedpadx)); thisbox->yratio = ((float)(y-usedpady))/((float)(usedy-usedpady)); -#ifdef DWDEBUG - fprintf(f, "WM_SIZE Resize Box Pass 1\r\nx = %d, y = %d, usedx = %d, usedy = %d, usedpadx = %d, usedpady = %d xratio = %f, yratio = %f\r\n\r\n", - x, y, usedx, usedy, usedpadx, usedpady, thisbox->xratio, thisbox->yratio); - reopen(); -#endif - usedpadx = usedpady = usedx = usedy = depth = 0; _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 2, &usedpadx, &usedpady); - -#ifdef DWDEBUG - fprintf(f, "WM_SIZE Resize Box Pass 2\r\nx = %d, y = %d, usedx = %d, usedy = %d, usedpadx = %d, usedpady = %d\r\n", - x, y, usedx, usedy, usedpadx, usedpady); - reopen(); -#endif } } } @@ -2755,9 +2707,6 @@ exit(1); } -#ifdef DWDEBUG - f = fopen("dw.log", "wt"); -#endif /* We need the version to check capability like up-down controls */ dwVersion = GetVersion(); dwComctlVer = GetDllVersion(TEXT("comctl32.dll")); @@ -2787,10 +2736,6 @@ TranslateMessage(&msg); DispatchMessage(&msg); } - -#ifdef DWDEBUG - fclose(f); -#endif } /* @@ -7187,153 +7132,3 @@ } } -#ifdef TEST -HWND mainwindow, - listbox, - okbutton, - cancelbutton, - lbbox, - stext, - buttonbox, - testwindow, - testbox, - testok, - testcancel, - testbox2, - testok2, - testcancel2, - notebook; -int count = 2; - -int test_callback(HWND window, void *data) -{ - dw_window_destroy((HWND)data); - /* Return -1 to allow the default handlers to return. */ - count--; - if(!count) - exit(0); - return -1; -} - -/* - * Let's demonstrate the functionality of this library. :) - */ -int main(int argc, char *argv[]) -{ - ULONG flStyle = DW_FCF_SYSMENU | DW_FCF_TITLEBAR | - DW_FCF_SHELLPOSITION | DW_FCF_TASKLIST | DW_FCF_DLGBORDER; - int pageid; - - dw_init(TRUE, argc, argv); - - /* Try a little server dialog. :) */ - mainwindow = dw_window_new(HWND_DESKTOP, "Server", flStyle | DW_FCF_SIZEBORDER | DW_FCF_MINMAX); - - lbbox = dw_box_new(BOXVERT, 10); - - dw_box_pack_start(mainwindow, lbbox, 0, 0, TRUE, TRUE, 0); - - stext = dw_text_new("Choose a server:", 0); - - dw_window_set_style(stext, DW_DT_VCENTER, DW_DT_VCENTER); - - dw_box_pack_start(lbbox, stext, 130, 15, FALSE, FALSE, 10); - - listbox = dw_listbox_new(100L, FALSE); - - dw_box_pack_start(lbbox, listbox, 130, 200, TRUE, TRUE, 10); - - buttonbox = dw_box_new(BOXHORZ, 0); - - dw_box_pack_start(lbbox, buttonbox, 0, 0, TRUE, TRUE, 0); - - okbutton = dw_button_new("Ok", 1001L); - - dw_box_pack_start(buttonbox, okbutton, 50, 30, TRUE, TRUE, 5); - - cancelbutton = dw_button_new("Cancel", 1002L); - - dw_box_pack_start(buttonbox, cancelbutton, 50, 30, TRUE, TRUE, 5); - - /* Set some nice fonts and colors */ - dw_window_set_color(lbbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); - dw_window_set_color(buttonbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); - dw_window_set_font(stext, "9.WarpSans"); - dw_window_set_color(stext, DW_CLR_BLACK, DW_CLR_PALEGRAY); - dw_window_set_font(listbox, "9.WarpSans"); - dw_window_set_font(okbutton, "9.WarpSans"); - dw_window_set_font(cancelbutton, "9.WarpSans"); - - dw_window_show(mainwindow); - - dw_window_set_usize(mainwindow, 170, 340); - - /* Another small example */ - flStyle |= DW_FCF_MINMAX | DW_FCF_SIZEBORDER; - - testwindow = dw_window_new(HWND_DESKTOP, "Wow a test dialog! :) yay!", flStyle); - - testbox = dw_box_new(BOXVERT, 0); - - dw_box_pack_start(testwindow, testbox, 0, 0, TRUE, TRUE, 0); - - notebook = dw_notebook_new(1010L, TRUE); - - dw_box_pack_start(testbox, notebook, 100, 100, TRUE, TRUE, 0); - - testbox = dw_box_new(BOXVERT, 10); - - pageid = dw_notebook_page_new(notebook, 0L, FALSE); - - dw_notebook_page_set_text(notebook, pageid, "Test page"); - dw_notebook_page_set_status_text(notebook, pageid, "Test page"); - - dw_notebook_pack(notebook, pageid, testbox); - - testok = dw_button_new("Ok", 1003L); - - dw_box_pack_start(testbox, testok, 60, 40, TRUE, TRUE, 10); - - testcancel = dw_button_new("Cancel", 1004L); - - dw_box_pack_start(testbox, testcancel, 60, 40, TRUE, TRUE, 10); - - testbox2 = dw_box_new(BOXHORZ, 0); - - dw_box_pack_start(testbox, testbox2, 0, 0, TRUE, TRUE, 0); - - testok2 = dw_button_new("Ok", 1003L); - - dw_box_pack_start(testbox2, testok2, 60, 40, TRUE, TRUE, 10); - - dw_box_pack_splitbar_start(testbox2); - - testcancel2 = dw_button_new("Cancel", 1004L); - - dw_box_pack_start(testbox2, testcancel2, 60, 40, TRUE, TRUE, 10); - - /* Set some nice fonts and colors */ - dw_window_set_color(testbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); - dw_window_set_color(testbox2, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY); - dw_window_set_font(testok, "9.WarpSans"); - dw_window_set_font(testcancel, "9.WarpSans"); - dw_window_set_font(testok2, "9.WarpSans"); - dw_window_set_font(testcancel2, "9.WarpSans"); - - dw_window_show(testwindow); - - /* Setup the function callbacks */ - dw_signal_connect(okbutton, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow); - dw_signal_connect(cancelbutton, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow); - dw_signal_connect(testok, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); - dw_signal_connect(testcancel, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); - dw_signal_connect(testok2, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); - dw_signal_connect(testcancel2, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); - dw_signal_connect(mainwindow, "delete_event", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow); - dw_signal_connect(testwindow, "delete_event", DW_SIGNAL_FUNC(test_callback), (void *)testwindow); - - dw_main(); - - return 0; -} -#endif \ No newline at end of file