Mercurial > dwindows
changeset 7:005fa766e8c2
Updates to latest build.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 03 Jul 2001 13:54:29 +0000 |
parents | 160798fd63c4 |
children | e22584460709 |
files | dw.def dw.h dww.def gtk/dw.c os2/dw.c win/dw.c |
diffstat | 6 files changed, 385 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/dw.def Tue Jul 03 12:56:13 2001 +0000 +++ b/dw.def Tue Jul 03 13:54:29 2001 +0000 @@ -59,6 +59,7 @@ dw_bitmapbutton_new @91 dw_text_new @100 + dw_status_text_new @101 dw_entryfield_new @110 dw_entryfield_password_new @111
--- a/dw.h Tue Jul 03 12:56:13 2001 +0000 +++ b/dw.h Tue Jul 03 13:54:29 2001 +0000 @@ -312,8 +312,10 @@ /* Ratio in this box */ float xratio, yratio, parentxratio, parentyratio; /* Used for calculating individual item ratios */ - int width, height; - /* Array of item structures */ + int width, height; + /* Any combinations of flags describing the box */ + unsigned long flags; + /* Array of item structures */ struct _item *items; } Box; @@ -504,6 +506,8 @@ #define DW_SIGNAL_FUNC(a) ((void *)a) +#define DW_MINIMIZED 1 + #define DW_BUTTON1_MASK 1 #define DW_BUTTON2_MASK (1 << 1) #define DW_BUTTON3_MASK (1 << 2) @@ -557,6 +561,7 @@ HWND dw_bitmapbutton_new(char *text, unsigned long id); HWND dw_container_new(unsigned long id); HWND dw_text_new(char *text, unsigned long id); +HWND dw_status_text_new(char *text, unsigned long id); HWND dw_mle_new(unsigned long id); HWND dw_entryfield_new(char *text, unsigned long id); HWND dw_entryfield_password_new(char *text, ULONG id); @@ -603,6 +608,8 @@ void dw_mle_thaw(HWND handle); void dw_mle_set(HWND handle, int point); void dw_mle_set_visible(HWND handle, int line); +void dw_mle_set_editable(HWND handle, int state); +void dw_mle_set_word_wrap(HWND handle, int state); int dw_mle_search(HWND handle, char *text, int point, unsigned long flags); void dw_spinbutton_set_pos(HWND handle, long position); void dw_spinbutton_set_limits(HWND handle, long upper, long lower);
--- a/dww.def Tue Jul 03 12:56:13 2001 +0000 +++ b/dww.def Tue Jul 03 13:54:29 2001 +0000 @@ -56,6 +56,7 @@ dw_bitmapbutton_new @91 dw_text_new @100 + dw_status_text_new @101 dw_entryfield_new @110 dw_entryfield_password_new @111
--- a/gtk/dw.c Tue Jul 03 12:56:13 2001 +0000 +++ b/gtk/dw.c Tue Jul 03 13:54:29 2001 +0000 @@ -944,7 +944,8 @@ HMENUI dw_menu_new(unsigned long id) { int _locked_by_me = FALSE; - HMENUI tmp = malloc(sizeof(struct _hmenui));; + HMENUI tmp = malloc(sizeof(struct _hmenui)); + GtkAccelGroup *accel_group; if(!tmp) return NULL; @@ -952,7 +953,9 @@ DW_MUTEX_LOCK; tmp->menu = gtk_menu_new(); gtk_widget_show(tmp->menu); + accel_group = gtk_accel_group_new(); gtk_object_set_data(GTK_OBJECT(tmp->menu), "id", (gpointer)id); + gtk_object_set_data(GTK_OBJECT(tmp->menu), "accel", (gpointer)accel_group); DW_MUTEX_UNLOCK; return tmp; } @@ -966,7 +969,8 @@ { GtkWidget *box; int _locked_by_me = FALSE; - HMENUI tmp = malloc(sizeof(struct _hmenui));; + HMENUI tmp = malloc(sizeof(struct _hmenui)); + GtkAccelGroup *accel_group; if(!tmp) return NULL; @@ -975,6 +979,8 @@ tmp->menu = gtk_menu_bar_new(); box = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(location)); gtk_widget_show(tmp->menu); + accel_group = gtk_accel_group_new(); + gtk_object_set_data(GTK_OBJECT(tmp->menu), "accel", (gpointer)accel_group); if(box) gtk_box_pack_end(GTK_BOX(box), tmp->menu, FALSE, FALSE, 0); @@ -1002,19 +1008,27 @@ } } -void _removetilde(char *dest, char *src) +char _removetilde(char *dest, char *src) { int z, cur=0; + char accel = '\0'; for(z=0;z<strlen(src);z++) { if(src[z] != '~') - { - dest[cur] = src[z]; - cur++; - } + { + dest[cur] = src[z]; + cur++; + } + else + { + dest[cur] = '_'; + accel = src[z+1]; + cur++; + } } dest[cur] = 0; + return accel; } /* @@ -1031,8 +1045,10 @@ HWND dw_menu_append_item(HMENUI menu, char *title, unsigned long id, unsigned long flags, int end, int check, HMENUI submenu) { GtkWidget *tmphandle; - char *tempbuf = malloc(strlen(title)+1); + char accel, *tempbuf = malloc(strlen(title)+1); int _locked_by_me = FALSE; + guint tmp_key; + GtkAccelGroup *accel_group; if(!menu || !menu->menu) { @@ -1041,7 +1057,9 @@ } DW_MUTEX_LOCK; - _removetilde(tempbuf, title); + accel = _removetilde(tempbuf, title); + + accel_group = (GtkAccelGroup *)gtk_object_get_data(GTK_OBJECT(menu->menu), "accel"); if(strlen(tempbuf) == 0) tmphandle=gtk_menu_item_new(); @@ -1050,13 +1068,29 @@ if(check) { char numbuf[10]; - tmphandle=gtk_check_menu_item_new_with_label(tempbuf); + if(accel && accel_group) + { + tmphandle=gtk_check_menu_item_new_with_label(""); + tmp_key = gtk_label_parse_uline(GTK_LABEL(GTK_BIN(tmphandle)->child), tempbuf); + gtk_widget_add_accelerator(tmphandle, "activate_item", accel_group, tmp_key, GDK_MOD1_MASK, 0); + } + else + tmphandle=gtk_check_menu_item_new_with_label(tempbuf); gtk_check_menu_item_set_show_toggle(GTK_CHECK_MENU_ITEM(tmphandle), TRUE); sprintf(numbuf, "%lu", id); gtk_object_set_data(GTK_OBJECT(menu->menu), numbuf, (gpointer)tmphandle); } else - tmphandle=gtk_menu_item_new_with_label(tempbuf); + { + if(accel && accel_group) + { + tmphandle=gtk_menu_item_new_with_label(""); + tmp_key = gtk_label_parse_uline(GTK_LABEL(GTK_BIN(tmphandle)->child), tempbuf); + gtk_widget_add_accelerator(tmphandle, "activate_item", accel_group, tmp_key, GDK_MOD1_MASK, 0); + } + else + tmphandle=gtk_menu_item_new_with_label(tempbuf); + } } gtk_widget_show(tmphandle); @@ -1197,6 +1231,26 @@ } /* + * Create a new status text window (widget) to be packed. + * Parameters: + * text: The text to be display by the static text widget. + * id: An ID to be used with WinWindowFromID() or 0L. + */ +HWND dw_status_text_new(char *text, ULONG id) +{ + GtkWidget *tmp; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + tmp = gtk_label_new(text); + gtk_label_set_justify(GTK_LABEL(tmp), GTK_JUSTIFY_LEFT); + gtk_widget_show(tmp); + gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id); + DW_MUTEX_UNLOCK; + return tmp; +} + +/* * Create a new Multiline Editbox window (widget) to be packed. * Parameters: * id: An ID to be used with WinWindowFromID() or 0L. @@ -1761,6 +1815,52 @@ } /* + * Sets the editablity of an MLE box. + * Parameters: + * handle: Handle to the MLE. + * state: TRUE if it can be edited, FALSE for readonly. + */ +void dw_mle_set_editable(HWND handle, int state) +{ + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + if(GTK_IS_BOX(handle)) + { + GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); + + if(tmp && GTK_IS_TEXT(tmp)) + { + gtk_text_set_editable(GTK_TEXT(tmp), state); + } + } + DW_MUTEX_UNLOCK; +} + +/* + * Sets the word wrap state of an MLE box. + * Parameters: + * handle: Handle to the MLE. + * state: TRUE if it wraps, FALSE if it doesn't. + */ +void dw_mle_set_word_wrap(HWND handle, int state) +{ + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + if(GTK_IS_BOX(handle)) + { + GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); + + if(tmp && GTK_IS_TEXT(tmp)) + { + gtk_text_set_word_wrap(GTK_TEXT(tmp), state); + } + } + DW_MUTEX_UNLOCK; +} + +/* * Sets the current cursor position of an MLE box. * Parameters: * handle: Handle to the MLE to be positioned.
--- a/os2/dw.c Tue Jul 03 12:56:13 2001 +0000 +++ b/os2/dw.c Tue Jul 03 13:54:29 2001 +0000 @@ -962,6 +962,67 @@ return WinDefWindowProc(hWnd, msg, mp1, mp2); } +/* This procedure handles drawing of a status border */ +MRESULT EXPENTRY _statusproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) +{ + PFNWP *blah = WinQueryWindowPtr(hWnd, QWP_USER); + + if(blah && *blah) + { + PFNWP myfunc = *blah; + + switch(msg) + { + case WM_PAINT: + { + HPS hpsPaint; + RECTL rclPaint; + POINTL ptl1, ptl2; + char buf[1024]; + + hpsPaint = WinBeginPaint(hWnd, 0, 0); + WinQueryWindowRect(hWnd, &rclPaint); + WinFillRect(hpsPaint, &rclPaint, CLR_PALEGRAY); + + GpiSetColor(hpsPaint, CLR_DARKGRAY); + ptl1.x = 0; + ptl2.y = ptl1.y = rclPaint.yTop - rclPaint.yBottom; + ptl2.x = rclPaint.xRight - rclPaint.xLeft; + GpiMove(hpsPaint, &ptl1); + GpiLine(hpsPaint, &ptl2); + ptl2.y = ptl2.x = 0; + GpiMove(hpsPaint, &ptl1); + GpiLine(hpsPaint, &ptl2); + + GpiSetColor(hpsPaint, CLR_WHITE); + ptl2.x = ptl1.x = rclPaint.xRight - rclPaint.xLeft; + ptl1.y = 0; + ptl2.y = rclPaint.yTop - rclPaint.yBottom; + GpiMove(hpsPaint, &ptl1); + GpiLine(hpsPaint, &ptl2); + ptl2.y = ptl2.x = 0; + GpiMove(hpsPaint, &ptl1); + GpiLine(hpsPaint, &ptl2); + + WinQueryWindowText(hWnd, 1024, buf); + rclPaint.xLeft += 3; + rclPaint.xRight--; + rclPaint.yTop--; + rclPaint.yBottom++; + + GpiSetColor(hpsPaint, CLR_BLACK); + WinDrawText(hpsPaint, -1, buf, &rclPaint, DT_TEXTATTRS, DT_TEXTATTRS, DT_VCENTER | DT_LEFT | DT_TEXTATTRS); + WinEndPaint(hpsPaint); + + return (MRESULT)TRUE; + } + } + return myfunc(hWnd, msg, mp1, mp2); + } + + return WinDefWindowProc(hWnd, msg, mp1, mp2); +} + /* Originally just intended for entryfields, it now serves as a generic * procedure for handling TAB presses to change input focus on controls. */ @@ -1411,7 +1472,7 @@ if(!SHORT1FROMMP(mp2) && !SHORT2FROMMP(mp2)) return (MPARAM)TRUE; - if(mybox) + if(mybox && mybox->flags != DW_MINIMIZED) { /* Hide the window when recalculating to reduce * CPU load. @@ -1429,10 +1490,18 @@ Box *mybox = (Box *)WinQueryWindowPtr(hWnd, QWP_USER); SWP *swp = (SWP *)mp1; + if(mybox && (swp->fl & SWP_MINIMIZE)) + mybox->flags = DW_MINIMIZED; + + if(mybox && (swp->fl & SWP_RESTORE)) + mybox->flags = 0; + if(mybox && (swp->fl & SWP_MAXIMIZE)) { int z; + mybox->flags = 0; + /* Hide the window when recalculating to reduce * CPU load. */ @@ -2509,7 +2578,7 @@ NULL, WS_VISIBLE | BKS_TABBEDDIALOG | - flags, + flags, 0,0,2000,1000, NULLHANDLE, HWND_TOP, @@ -2747,6 +2816,33 @@ } /* + * Create a new status text window (widget) to be packed. + * Parameters: + * text: The text to be display by the static text widget. + * id: An ID to be used with WinWindowFromID() or 0L. + */ +HWND dw_status_text_new(char *text, ULONG id) +{ + PFNWP *blah = malloc(sizeof(PFNWP)); + HWND tmp = WinCreateWindow(HWND_OBJECT, + WC_STATIC, + text, + WS_VISIBLE | SS_TEXT, + 0,0,2000,1000, + NULLHANDLE, + HWND_TOP, + id, + NULL, + NULL); + dw_window_set_font(tmp, DefaultFont); + dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY); + + *blah = WinSubclassWindow(tmp, _statusproc); + WinSetWindowPtr(tmp, QWP_USER, blah); + return tmp; +} + +/* * Create a new Multiline Editbox window (widget) to be packed. * Parameters: * id: An ID to be used with WinWindowFromID() or 0L. @@ -2953,8 +3049,7 @@ * text: The text to be display by the static text widget. * id: An ID to be used with WinWindowFromID() or 0L. */ -HWND -dw_spinbutton_new(char *text, ULONG id) +HWND dw_spinbutton_new(char *text, ULONG id) { PFNWP *blah = malloc(sizeof(PFNWP)); HWND tmp = WinCreateWindow(HWND_OBJECT, @@ -3773,6 +3868,27 @@ } /* + * Sets the editablity of an MLE box. + * Parameters: + * handle: Handle to the MLE. + * state: TRUE if it can be edited, FALSE for readonly. + */ +void dw_mle_set_editable(HWND handle, int state) +{ + WinSendMsg(handle, MLM_SETREADONLY, MPFROMLONG(state ? FALSE : TRUE), 0); +} + +/* + * Sets the word wrap state of an MLE box. + * Parameters: + * handle: Handle to the MLE. + * state: TRUE if it wraps, FALSE if it doesn't. + */ +void dw_mle_set_word_wrap(HWND handle, int state) +{ +} + +/* * Sets the current cursor position of an MLE box. * Parameters: * handle: Handle to the MLE to be positioned.
--- a/win/dw.c Tue Jul 03 12:56:13 2001 +0000 +++ b/win/dw.c Tue Jul 03 13:54:29 2001 +0000 @@ -1747,6 +1747,73 @@ return DefWindowProc(hwnd, msg, mp1, mp2); } +/* This handles drawing the status text areas */ +BOOL CALLBACK _statuswndproc(HWND hwnd, UINT msg, WPARAM mp1, LPARAM mp2) +{ + switch (msg) + { + case WM_PAINT: + { + HDC hdcPaint; + PAINTSTRUCT ps; + RECT rcPaint; + HBRUSH hBrush; + HPEN hPen; + HFONT hFont; + char tempbuf[1024] = ""; + + hdcPaint = BeginPaint(hwnd, &ps); + GetWindowRect(hwnd, &rcPaint); + + dw_color_foreground_set(DW_RGB(_red[DW_CLR_PALEGRAY], + _green[DW_CLR_PALEGRAY], + _blue[DW_CLR_PALEGRAY])); + + dw_draw_rect(hwnd, 0, TRUE, 1, 1, rcPaint.right - rcPaint.left - 2, rcPaint.bottom - rcPaint.top - 2); + + dw_color_foreground_set(DW_RGB(_red[DW_CLR_DARKGRAY], + _green[DW_CLR_DARKGRAY], + _blue[DW_CLR_DARKGRAY])); + + dw_draw_line(hwnd, 0, 0, 0, rcPaint.right - rcPaint.left, 0); + dw_draw_line(hwnd, 0, 0, 0, 0, rcPaint.bottom - rcPaint.top); + + dw_color_foreground_set(DW_RGB(_red[DW_CLR_WHITE], + _green[DW_CLR_WHITE], + _blue[DW_CLR_WHITE])); + + dw_draw_line(hwnd, 0, rcPaint.right - rcPaint.left - 1, rcPaint.bottom - rcPaint.top - 1, rcPaint.right - rcPaint.left - 1, 0); + dw_draw_line(hwnd, 0, rcPaint.right - rcPaint.left - 1, rcPaint.bottom - rcPaint.top - 1, 0, rcPaint.bottom - rcPaint.top - 1); + + rcPaint.left += 3; + rcPaint.top++; + rcPaint.bottom--; + rcPaint.right--; + + GetWindowText(hwnd, tempbuf, 1024); + + dw_color_foreground_set(DW_RGB(_red[DW_CLR_BLACK], + _green[DW_CLR_BLACK], + _blue[DW_CLR_BLACK])); + + hBrush = (HBRUSH)SelectObject(hdcPaint, _hBrush); + hPen = (HPEN)SelectObject(hdcPaint, _hPen); + hFont = (HFONT)SelectObject(hdcPaint, GetStockObject(DEFAULT_GUI_FONT)); + + ExtTextOut(hdcPaint, rcPaint.left, rcPaint.top, ETO_CLIPPED, + &rcPaint, tempbuf, strlen(tempbuf), NULL); + + SelectObject(hdcPaint, hBrush); + SelectObject(hdcPaint, hPen); + SelectObject(hdcPaint, hFont); + + EndPaint(hwnd, &ps); + } + return FALSE; + } + return DefWindowProc(hwnd, msg, mp1, mp2); +} + /* Function: _BtProc * Abstract: Subclass procedure for buttons */ @@ -2319,6 +2386,21 @@ if(strnicmp(tmpbuf, FRAMECLASSNAME, strlen(FRAMECLASSNAME))==0) return FALSE; + if(strnicmp(tmpbuf, WC_LISTVIEW, strlen(WC_LISTVIEW))==0) + { + ListView_SetTextColor(handle, RGB(DW_RED_VALUE(fore), + DW_GREEN_VALUE(fore), + DW_BLUE_VALUE(fore))); + ListView_SetTextBkColor(handle, RGB(DW_RED_VALUE(back), + DW_GREEN_VALUE(back), + DW_BLUE_VALUE(back))); + ListView_SetBkColor(handle, RGB(DW_RED_VALUE(back), + DW_GREEN_VALUE(back), + DW_BLUE_VALUE(back))); + InvalidateRgn(handle, NULL, TRUE); + return TRUE; + } + if(cinfo) { cinfo->fore = fore; @@ -2335,6 +2417,7 @@ cinfo->pOldProc = SubclassWindow(handle, _colorwndproc); SetWindowLong(handle, GWL_USERDATA, (ULONG)cinfo); } + InvalidateRgn(handle, NULL, TRUE); return TRUE; } @@ -2737,18 +2820,39 @@ HWND dw_text_new(char *text, ULONG id) { HWND tmp = CreateWindow(STATICCLASSNAME, - text, - BS_TEXT | WS_CHILD | WS_CLIPCHILDREN, - 0,0,2000,1000, - DW_HWND_OBJECT, - (HMENU)id, - NULL, - NULL); + text, + BS_TEXT | WS_CHILD | WS_CLIPCHILDREN, + 0,0,2000,1000, + DW_HWND_OBJECT, + (HMENU)id, + NULL, + NULL); dw_window_set_font(tmp, DefaultFont); return tmp; } /* + * Create a new status text window (widget) to be packed. + * Parameters: + * text: The text to be display by the static text widget. + * id: An ID to be used with WinWindowFromID() or 0L. + */ +HWND dw_status_text_new(char *text, ULONG id) +{ + HWND tmp = CreateWindow(STATICCLASSNAME, + text, + BS_TEXT | WS_CHILD | WS_CLIPCHILDREN, + 0,0,2000,1000, + DW_HWND_OBJECT, + (HMENU)id, + NULL, + NULL); + dw_window_set_font(tmp, DefaultFont); + SubclassWindow(tmp, _statuswndproc); + return tmp; +} + +/* * Create a new Multiline Editbox window (widget) to be packed. * Parameters: * id: An ID to be used with WinWindowFromID() or 0L. @@ -3904,6 +4008,27 @@ } /* + * Sets the editablity of an MLE box. + * Parameters: + * handle: Handle to the MLE. + * state: TRUE if it can be edited, FALSE for readonly. + */ +void dw_mle_set_editable(HWND handle, int state) +{ + SendMessage(handle, EM_SETREADONLY, (WPARAM)(state ? FALSE : TRUE), 0); +} + +/* + * Sets the word wrap state of an MLE box. + * Parameters: + * handle: Handle to the MLE. + * state: TRUE if it wraps, FALSE if it doesn't. + */ +void dw_mle_set_word_wrap(HWND handle, int state) +{ +} + +/* * Sets the current cursor position of an MLE box. * Parameters: * handle: Handle to the MLE to be positioned. @@ -4186,6 +4311,16 @@ */ void *dw_container_alloc(HWND handle, int rowcount) { + LV_ITEM lvi; + int z; + + lvi.mask = LVIF_DI_SETITEM | LVIF_TEXT; + lvi.iSubItem = 0; + lvi.pszText = ""; + lvi.cchTextMax = 1; + + for(z=0;z<rowcount;z++) + ListView_InsertItem(handle, &lvi); return (void *)handle; } @@ -4337,10 +4472,7 @@ lvi.cchTextMax = strlen(textbuffer); } - if(column == 0) - ListView_InsertItem(handle, &lvi); - else - ListView_SetItemText(handle, row, column, destptr); + ListView_SetItemText(handle, row, column, destptr); } /* @@ -4361,10 +4493,7 @@ lvi.lParam = (LPARAM)title; if(!ListView_SetItem(container, &lvi) && lvi.lParam) - { - free((void *)lvi.lParam); lvi.lParam = 0; - } }