Mercurial > dwindows
comparison win/dw.c @ 14:176cee043f1b
Lots of Windows and Unix bug fixes.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Wed, 11 Jul 2001 21:57:56 +0000 |
parents | 26e2130135b9 |
children | 81833f25b1aa |
comparison
equal
deleted
inserted
replaced
13:156281539fb3 | 14:176cee043f1b |
---|---|
14 #include <string.h> | 14 #include <string.h> |
15 #include <stdio.h> | 15 #include <stdio.h> |
16 #include <process.h> | 16 #include <process.h> |
17 #include "dw.h" | 17 #include "dw.h" |
18 | 18 |
19 /* Get around apparent bugs in the | |
20 * Microsoft runtime when in the debugger. | |
21 * You can set this value to 0 when releasing. | |
22 */ | |
23 #define DEBUG_MALLOC 100 | |
24 | |
25 /* this is the callback handle for the window procedure */ | 19 /* this is the callback handle for the window procedure */ |
26 /* make sure you always match the calling convention! */ | 20 /* make sure you always match the calling convention! */ |
27 int (*filterfunc)(HWND, UINT, WPARAM, LPARAM) = 0L; | 21 int (*filterfunc)(HWND, UINT, WPARAM, LPARAM) = 0L; |
28 | 22 |
29 HWND hwndBubble = (HWND)NULL, hwndBubbleLast, DW_HWND_OBJECT = (HWND)NULL; | 23 HWND hwndBubble = (HWND)NULL, hwndBubbleLast, DW_HWND_OBJECT = (HWND)NULL; |
101 char name[30]; | 95 char name[30]; |
102 | 96 |
103 } SignalList; | 97 } SignalList; |
104 | 98 |
105 /* List of signals and their equivilent Win32 message */ | 99 /* List of signals and their equivilent Win32 message */ |
106 #define SIGNALMAX 11 | 100 #define SIGNALMAX 12 |
107 | 101 |
108 SignalList SignalTranslate[SIGNALMAX] = { | 102 SignalList SignalTranslate[SIGNALMAX] = { |
109 { WM_SIZE, "configure_event" }, | 103 { WM_SIZE, "configure_event" }, |
110 { WM_CHAR, "key_press_event" }, | 104 { WM_CHAR, "key_press_event" }, |
111 { WM_LBUTTONDOWN, "button_press_event" }, | 105 { WM_LBUTTONDOWN, "button_press_event" }, |
114 { WM_CLOSE, "delete_event" }, | 108 { WM_CLOSE, "delete_event" }, |
115 { WM_PAINT, "expose_event" }, | 109 { WM_PAINT, "expose_event" }, |
116 { WM_COMMAND, "clicked" }, | 110 { WM_COMMAND, "clicked" }, |
117 { NM_DBLCLK, "container-select" }, | 111 { NM_DBLCLK, "container-select" }, |
118 { NM_RCLICK, "container-context" }, | 112 { NM_RCLICK, "container-context" }, |
119 { LBN_SELCHANGE, "item-select" } | 113 { LBN_SELCHANGE, "item-select" }, |
114 { WM_SETFOCUS, "set-focus" } | |
120 }; | 115 }; |
121 | 116 |
122 #ifdef BUILD_DLL | 117 #ifdef BUILD_DLL |
123 void Win32_Set_Instance(HINSTANCE hInstance) | 118 void Win32_Set_Instance(HINSTANCE hInstance) |
124 { | 119 { |
977 { | 972 { |
978 if(tmp->message == msg || msg == WM_COMMAND) | 973 if(tmp->message == msg || msg == WM_COMMAND) |
979 { | 974 { |
980 switch(msg) | 975 switch(msg) |
981 { | 976 { |
977 case WM_SETFOCUS: | |
978 { | |
979 int (*setfocusfunc)(HWND, void *) = (int (*)(HWND, void *))tmp->signalfunction; | |
980 | |
981 if(hWnd == tmp->window) | |
982 { | |
983 result = setfocusfunc(tmp->window, tmp->data); | |
984 tmp = NULL; | |
985 } | |
986 } | |
987 break; | |
982 case WM_SIZE: | 988 case WM_SIZE: |
983 { | 989 { |
984 int (*sizefunc)(HWND, int, int, void *) = tmp->signalfunction; | 990 int (*sizefunc)(HWND, int, int, void *) = tmp->signalfunction; |
985 | 991 |
986 if(hWnd == tmp->window) | 992 if(hWnd == tmp->window) |
2053 * Initializes the Dynamic Windows engine. | 2059 * Initializes the Dynamic Windows engine. |
2054 * Parameters: | 2060 * Parameters: |
2055 * newthread: True if this is the only thread. | 2061 * newthread: True if this is the only thread. |
2056 * False if there is already a message loop running. | 2062 * False if there is already a message loop running. |
2057 */ | 2063 */ |
2058 int dw_init(int newthread) | 2064 int dw_init(int newthread, int argc, char *argv[]) |
2059 { | 2065 { |
2060 WNDCLASS wc; | 2066 WNDCLASS wc; |
2061 int z; | 2067 int z; |
2062 INITCOMMONCONTROLSEX icc; | 2068 INITCOMMONCONTROLSEX icc; |
2063 | 2069 |
2274 int dw_yesno(char *title, char *text) | 2280 int dw_yesno(char *title, char *text) |
2275 { | 2281 { |
2276 if(MessageBox(HWND_DESKTOP, text, title, MB_YESNO)==IDYES) | 2282 if(MessageBox(HWND_DESKTOP, text, title, MB_YESNO)==IDYES) |
2277 return TRUE; | 2283 return TRUE; |
2278 return FALSE; | 2284 return FALSE; |
2285 } | |
2286 | |
2287 /* | |
2288 * Minimizes or Iconifies a top-level window. | |
2289 * Parameters: | |
2290 * handle: The window handle to minimize. | |
2291 */ | |
2292 int dw_window_minimize(HWND handle) | |
2293 { | |
2294 return ShowWindow(handle, SW_MINIMIZE); | |
2279 } | 2295 } |
2280 | 2296 |
2281 /* | 2297 /* |
2282 * Makes the window visible. | 2298 * Makes the window visible. |
2283 * Parameters: | 2299 * Parameters: |
2514 hwndframe = CreateWindowEx(flStyleEx, ClassName, title, flStyle | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, | 2530 hwndframe = CreateWindowEx(flStyleEx, ClassName, title, flStyle | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, |
2515 CW_USEDEFAULT, CW_USEDEFAULT, hwndOwner, NULL, NULL, NULL); | 2531 CW_USEDEFAULT, CW_USEDEFAULT, hwndOwner, NULL, NULL, NULL); |
2516 } | 2532 } |
2517 SetWindowLong(hwndframe, GWL_USERDATA, (ULONG)newbox); | 2533 SetWindowLong(hwndframe, GWL_USERDATA, (ULONG)newbox); |
2518 | 2534 |
2535 #if 0 | |
2519 if(hwndOwner) | 2536 if(hwndOwner) |
2520 SetParent(hwndframe, hwndOwner); | 2537 SetParent(hwndframe, hwndOwner); |
2538 #endif | |
2521 | 2539 |
2522 return hwndframe; | 2540 return hwndframe; |
2523 } | 2541 } |
2524 | 2542 |
2525 /* | 2543 /* |
2528 * type: Either BOXVERT (vertical) or BOXHORZ (horizontal). | 2546 * type: Either BOXVERT (vertical) or BOXHORZ (horizontal). |
2529 * pad: Number of pixels to pad around the box. | 2547 * pad: Number of pixels to pad around the box. |
2530 */ | 2548 */ |
2531 HWND dw_box_new(int type, int pad) | 2549 HWND dw_box_new(int type, int pad) |
2532 { | 2550 { |
2533 Box *newbox = malloc(sizeof(Box)+DEBUG_MALLOC); | 2551 Box *newbox = malloc(sizeof(Box)); |
2534 HWND hwndframe; | 2552 HWND hwndframe; |
2535 | 2553 |
2536 newbox->pad = pad; | 2554 newbox->pad = pad; |
2537 newbox->type = type; | 2555 newbox->type = type; |
2538 newbox->count = 0; | 2556 newbox->count = 0; |
2593 dw_window_set_font(newbox->grouphwnd, DefaultFont); | 2611 dw_window_set_font(newbox->grouphwnd, DefaultFont); |
2594 return hwndframe; | 2612 return hwndframe; |
2595 } | 2613 } |
2596 | 2614 |
2597 /* | 2615 /* |
2616 * Create a new MDI Frame to be packed. | |
2617 * Parameters: | |
2618 * id: An ID to be used with dw_window_from_id or 0L. | |
2619 */ | |
2620 HWND dw_mdi_new(unsigned long id) | |
2621 { | |
2622 CLIENTCREATESTRUCT ccs; | |
2623 HWND hwndframe; | |
2624 | |
2625 ccs.hWindowMenu = NULL; | |
2626 ccs.idFirstChild = 0; | |
2627 | |
2628 hwndframe = CreateWindow("MDICLIENT", | |
2629 "", | |
2630 WS_CHILD | WS_CLIPSIBLINGS, | |
2631 0,0,2000,1000, | |
2632 DW_HWND_OBJECT, | |
2633 NULL, | |
2634 DWInstance, | |
2635 &ccs); | |
2636 return hwndframe; | |
2637 } | |
2638 | |
2639 /* | |
2598 * Create a bitmap object to be packed. | 2640 * Create a bitmap object to be packed. |
2599 * Parameters: | 2641 * Parameters: |
2600 * id: An ID to be used with WinWindowFromID() or 0L. | 2642 * id: An ID to be used with dw_window_from_id or 0L. |
2601 */ | 2643 */ |
2602 HWND dw_bitmap_new(ULONG id) | 2644 HWND dw_bitmap_new(ULONG id) |
2603 { | 2645 { |
2604 return CreateWindow(STATICCLASSNAME, | 2646 return CreateWindow(STATICCLASSNAME, |
2605 "", | 2647 "", |
3339 { | 3381 { |
3340 int z; | 3382 int z; |
3341 Item *tmpitem, *thisitem = thisbox->items; | 3383 Item *tmpitem, *thisitem = thisbox->items; |
3342 char tmpbuf[100]; | 3384 char tmpbuf[100]; |
3343 | 3385 |
3344 tmpitem = malloc(sizeof(Item)*(thisbox->count+1)+DEBUG_MALLOC); | 3386 tmpitem = malloc(sizeof(Item)*(thisbox->count+1)); |
3345 | 3387 |
3346 for(z=0;z<thisbox->count;z++) | 3388 for(z=0;z<thisbox->count;z++) |
3347 { | 3389 { |
3348 tmpitem[z] = thisitem[z]; | 3390 tmpitem[z] = thisitem[z]; |
3349 } | 3391 } |