annotate win/dw.c @ 337:e9a424e641ff

Some pointer changes.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 10 Apr 2003 12:33:29 +0000
parents a2f72b5d5d0a
children 4482dd0bb87d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1 /*
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
2 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3 * Dynamic Windows:
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4 * A GTK like implementation of the Win32 GUI
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5 *
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
6 * (C) 2000-2003 Brian Smith <dbsoft@technologist.com>
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7 *
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8 */
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9 #define _WIN32_IE 0x0500
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
10 #define WINVER 0x400
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
11 #include <windows.h>
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
12 #include <windowsx.h>
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
13 #include <commctrl.h>
75
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
14 #include <shlwapi.h>
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
15 #include <stdlib.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
16 #include <string.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
17 #include <stdio.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
18 #include <process.h>
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
19 #include <time.h>
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
20 #include "dw.h"
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
21
93
98cce029a611 Changed handling of menu item click events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 90
diff changeset
22 HWND popup = (HWND)NULL, hwndBubble = (HWND)NULL, hwndBubbleLast, DW_HWND_OBJECT = (HWND)NULL;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
23
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
24 HINSTANCE DWInstance = NULL;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
25
75
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
26 DWORD dwVersion = 0, dwComctlVer = 0;
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
27 DWTID _dwtid = -1;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
28
75
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
29 #define PACKVERSION(major,minor) MAKELONG(minor,major)
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
30
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
31 #define IS_IE5PLUS (dwComctlVer >= PACKVERSION(5,80))
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
32
95
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
33 #ifndef MIN
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
34 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
35 #endif
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
36
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
37 int main(int argc, char *argv[]);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
38
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
39 #define ICON_INDEX_LIMIT 200
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
40 HICON lookup[200];
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
41 HIMAGELIST hSmall = 0, hLarge = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
42
105
ad95fc623ff3 Some changes to the container optimization code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 104
diff changeset
43 /* Special flag used for internal tracking */
ad95fc623ff3 Some changes to the container optimization code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 104
diff changeset
44 #define DW_CFA_RESERVED (1 << 30)
ad95fc623ff3 Some changes to the container optimization code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 104
diff changeset
45
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
46 #define THREAD_LIMIT 128
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
47 COLORREF _foreground[THREAD_LIMIT];
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
48 COLORREF _background[THREAD_LIMIT];
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
49 HPEN _hPen[THREAD_LIMIT];
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
50 HBRUSH _hBrush[THREAD_LIMIT];
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
51
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
52 BYTE _red[] = { 0x00, 0xbb, 0x00, 0xaa, 0x00, 0xbb, 0x00, 0xaa, 0x77,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
53 0xff, 0x00, 0xee, 0x00, 0xff, 0x00, 0xff, 0xaa, 0x00 };
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
54 BYTE _green[] = { 0x00, 0x00, 0xbb, 0xaa, 0x00, 0x00, 0xbb, 0xaa, 0x77,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
55 0x00, 0xff, 0xee, 0x00, 0x00, 0xee, 0xff, 0xaa, 0x00 };
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
56 BYTE _blue[] = { 0x00, 0x00, 0x00, 0x00, 0xcc, 0xbb, 0xbb, 0xaa, 0x77,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
57 0x00, 0x00, 0x00, 0xff, 0xff, 0xee, 0xff, 0xaa, 0x00};
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
59 HBRUSH _colors[18];
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
60
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
61
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
62 void _resize_notebook_page(HWND handle, int pageid);
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
63 void _handle_splitbar_resize(HWND hwnd, float percent, int type, int x, int y);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
64 int _lookup_icon(HWND handle, HICON hicon, int type);
299
2a97f8d9b297 Use DrawStatusText() to make the status lines, instead of doing it ourself.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 298
diff changeset
65 HFONT _acquire_font(HWND handle, char *fontname);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
66
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
67 typedef struct _sighandler
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
68 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
69 struct _sighandler *next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
70 ULONG message;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
71 HWND window;
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
72 int id;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
73 void *signalfunction;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
74 void *data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
75
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
76 } SignalHandler;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
77
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
78 SignalHandler *Root = NULL;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
79 int _index;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
80
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
81 typedef struct
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
82 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
83 ULONG message;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
84 char name[30];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
85
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
86 } SignalList;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
87
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
88 static int in_checkbox_handler = 0;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
89
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
90 /* List of signals and their equivilent Win32 message */
332
7b0f00729a32 Implement switch-page signal for notebooks. Bit of a bug in that it fires
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 328
diff changeset
91 #define SIGNALMAX 15
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
92
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
93 SignalList SignalTranslate[SIGNALMAX] = {
307
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 303
diff changeset
94 { WM_SIZE, DW_SIGNAL_CONFIGURE },
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 303
diff changeset
95 { WM_CHAR, DW_SIGNAL_KEY_PRESS },
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 303
diff changeset
96 { WM_LBUTTONDOWN, DW_SIGNAL_BUTTON_PRESS },
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 303
diff changeset
97 { WM_LBUTTONUP, DW_SIGNAL_BUTTON_PRESS },
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 303
diff changeset
98 { WM_MOUSEMOVE, DW_SIGNAL_MOTION_NOTIFY },
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 303
diff changeset
99 { WM_CLOSE, DW_SIGNAL_DELETE },
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 303
diff changeset
100 { WM_PAINT, DW_SIGNAL_EXPOSE },
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 303
diff changeset
101 { WM_COMMAND, DW_SIGNAL_CLICKED },
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 303
diff changeset
102 { NM_DBLCLK, DW_SIGNAL_ITEM_ENTER },
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 303
diff changeset
103 { NM_RCLICK, DW_SIGNAL_ITEM_CONTEXT },
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 303
diff changeset
104 { LBN_SELCHANGE, DW_SIGNAL_LIST_SELECT },
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 303
diff changeset
105 { TVN_SELCHANGED, DW_SIGNAL_ITEM_SELECT },
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 303
diff changeset
106 { WM_SETFOCUS, DW_SIGNAL_SET_FOCUS },
332
7b0f00729a32 Implement switch-page signal for notebooks. Bit of a bug in that it fires
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 328
diff changeset
107 { WM_VSCROLL, DW_SIGNAL_VALUE_CHANGED },
7b0f00729a32 Implement switch-page signal for notebooks. Bit of a bug in that it fires
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 328
diff changeset
108 { TCN_SELCHANGE, DW_SIGNAL_SWITCH_PAGE }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
109 };
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
110
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
111 #ifdef BUILD_DLL
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
112 void Win32_Set_Instance(HINSTANCE hInstance)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
113 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
114 DWInstance = hInstance;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
115 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
116 #else
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
117 char **_convertargs(int *count, char *start)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
118 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
119 char *tmp, *argstart, **argv;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
120 int loc = 0, inquotes = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
121
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
122 (*count) = 1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
123
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
124 tmp = start;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
125
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
126 /* Count the number of entries */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
127 if(*start)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
128 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
129 (*count)++;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
130
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
131 while(*tmp)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
132 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
133 if(*tmp == '"' && inquotes)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
134 inquotes = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
135 else if(*tmp == '"' && !inquotes)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
136 inquotes = 1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
137 else if(*tmp == ' ' && !inquotes)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
138 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
139 /* Push past any white space */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
140 while(*(tmp+1) == ' ')
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
141 tmp++;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
142 /* If we aren't at the end of the command
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
143 * line increment the count.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
144 */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
145 if(*(tmp+1))
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
146 (*count)++;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
147 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
148 tmp++;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
149 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
150 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
151
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
152 argv = (char **)malloc(sizeof(char *) * ((*count)+1));
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
153 argv[0] = malloc(260);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
154 GetModuleFileName(DWInstance, argv[0], 260);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
155
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
156 argstart = tmp = start;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
157
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
158 if(*start)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
159 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
160 loc = 1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
161
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
162 while(*tmp)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
163 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
164 if(*tmp == '"' && inquotes)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
165 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
166 *tmp = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
167 inquotes = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
168 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
169 else if(*tmp == '"' && !inquotes)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
170 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
171 argstart = tmp+1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
172 inquotes = 1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
173 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
174 else if(*tmp == ' ' && !inquotes)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
175 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
176 *tmp = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
177 argv[loc] = strdup(argstart);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
178
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
179 /* Push past any white space */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
180 while(*(tmp+1) == ' ')
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
181 tmp++;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
182
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
183 /* Move the start pointer */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
184 argstart = tmp+1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
185
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
186 /* If we aren't at the end of the command
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
187 * line increment the count.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
188 */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
189 if(*(tmp+1))
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
190 loc++;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
191 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
192 tmp++;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
193 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
194 if(*argstart)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
195 argv[loc] = strdup(argstart);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
196 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
197 argv[loc+1] = NULL;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
198 return argv;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
199 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
200
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
201 /* Ok this is a really big hack but what the hell ;) */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
202 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
203 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
204 char **argv;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
205 int argc;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
206
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
207 DWInstance = hInstance;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
208
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
209 argv = _convertargs(&argc, lpCmdLine);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
210
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
211 return main(argc, argv);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
212 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
213 #endif
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
214
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
215 /* This should return true for WinNT/2K/XP and false on Win9x */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
216 int IsWinNT(void)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
217 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
218 static int isnt = -1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
219
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
220 if(isnt == -1)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
221 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
222 if (GetVersion() < 0x80000000)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
223 isnt = 1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
224 else
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
225 isnt = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
226 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
227 return isnt;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
228 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
229
75
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
230 DWORD GetDllVersion(LPCTSTR lpszDllName)
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
231 {
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
232
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
233 HINSTANCE hinstDll;
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
234 DWORD dwVersion = 0;
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
235
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
236 hinstDll = LoadLibrary(lpszDllName);
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
237
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
238 if(hinstDll)
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
239 {
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
240 DLLGETVERSIONPROC pDllGetVersion;
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
241
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
242 pDllGetVersion = (DLLGETVERSIONPROC) GetProcAddress(hinstDll, "DllGetVersion");
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
243
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
244 /* Because some DLLs might not implement this function, you
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
245 * must test for it explicitly. Depending on the particular
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
246 * DLL, the lack of a DllGetVersion function can be a useful
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
247 * indicator of the version.
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
248 */
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
249 if(pDllGetVersion)
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
250 {
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
251 DLLVERSIONINFO dvi;
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
252 HRESULT hr;
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
253
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
254 ZeroMemory(&dvi, sizeof(dvi));
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
255 dvi.cbSize = sizeof(dvi);
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
256
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
257 hr = (*pDllGetVersion)(&dvi);
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
258
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
259 if(SUCCEEDED(hr))
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
260 {
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
261 dwVersion = PACKVERSION(dvi.dwMajorVersion, dvi.dwMinorVersion);
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
262 }
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
263 }
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
264
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
265 FreeLibrary(hinstDll);
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
266 }
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
267 return dwVersion;
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
268 }
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
269
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
270 /* This function adds a signal handler callback into the linked list.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
271 */
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
272 void _new_signal(ULONG message, HWND window, int id, void *signalfunction, void *data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
273 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
274 SignalHandler *new = malloc(sizeof(SignalHandler));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
275
55
b6948eac375a Sync with the latest dynamic windows, tree fixes, and other miscellaneous
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 54
diff changeset
276 if(message == WM_COMMAND)
b6948eac375a Sync with the latest dynamic windows, tree fixes, and other miscellaneous
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 54
diff changeset
277 dw_signal_disconnect_by_window(window);
b6948eac375a Sync with the latest dynamic windows, tree fixes, and other miscellaneous
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 54
diff changeset
278
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
279 new->message = message;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
280 new->window = window;
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
281 new->id = id;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
282 new->signalfunction = signalfunction;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
283 new->data = data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
284 new->next = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
285
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
286 if (!Root)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
287 Root = new;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
288 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
289 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
290 SignalHandler *prev = NULL, *tmp = Root;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
291 while(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
292 {
68
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
293 if(tmp->message == message &&
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
294 tmp->window == window &&
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
295 tmp->signalfunction == signalfunction)
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
296 {
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
297 tmp->data = data;
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
298 free(new);
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
299 return;
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
300 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
301 prev = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
302 tmp = tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
303 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
304 if(prev)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
305 prev->next = new;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
306 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
307 Root = new;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
308 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
309 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
310
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
311 /* Finds the message number for a given signal name */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
312 ULONG _findsigmessage(char *signame)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
313 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
314 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
315
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
316 for(z=0;z<SIGNALMAX;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
317 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
318 if(stricmp(signame, SignalTranslate[z].name) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
319 return SignalTranslate[z].message;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
320 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
321 return 0L;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
322 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
323
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
324 /* This function removes and handlers on windows and frees
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
325 * the user memory allocated to it.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
326 */
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
327 BOOL CALLBACK _free_window_memory(HWND handle, LPARAM lParam)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
328 {
82
aec9a0b0b539 Fixes for a resource leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 79
diff changeset
329 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA);
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
330 HFONT oldfont = (HFONT)SendMessage(handle, WM_GETFONT, 0, 0);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
331 HICON oldicon = (HICON)SendMessage(handle, WM_GETICON, 0, 0);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
332 char tmpbuf[100];
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
333
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
334 /* Delete font, icon and bitmap GDI objects in use */
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
335 if(oldfont)
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
336 DeleteObject(oldfont);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
337 if(oldicon)
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
338 DeleteObject(oldicon);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
339
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
340 GetClassName(handle, tmpbuf, 99);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
341
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
342 if(strnicmp(tmpbuf, STATICCLASSNAME, strlen(STATICCLASSNAME)+1)==0)
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
343 {
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
344 HBITMAP oldbitmap = (HBITMAP)SendMessage(handle, STM_GETIMAGE, IMAGE_BITMAP, 0);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
345
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
346 if(oldbitmap)
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
347 DeleteObject(oldbitmap);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
348 }
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
349 if(strnicmp(tmpbuf, BUTTONCLASSNAME, strlen(BUTTONCLASSNAME)+1)==0)
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
350 {
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
351 HBITMAP oldbitmap = (HBITMAP)SendMessage(handle, BM_GETIMAGE, IMAGE_BITMAP, 0);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
352
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
353 if(oldbitmap)
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
354 DeleteObject(oldbitmap);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
355 }
180
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
356 else if(strnicmp(tmpbuf, FRAMECLASSNAME, strlen(FRAMECLASSNAME)+1)==0)
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
357 {
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
358 Box *box = (Box *)thiscinfo;
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
359
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
360 if(box->count && box->items)
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
361 free(box->items);
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
362 }
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
363 else if(strnicmp(tmpbuf, SplitbarClassName, strlen(SplitbarClassName)+1)==0)
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
364 {
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
365 void *data = dw_window_get_data(handle, "_dw_percent");
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
366
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
367 if(data)
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
368 free(data);
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
369 }
291
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
370 else if(strnicmp(tmpbuf, WC_TREEVIEW, strlen(WC_TREEVIEW)+1)==0)
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
371 {
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
372 dw_tree_clear(handle);
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
373 }
180
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
374 else if(strnicmp(tmpbuf, WC_TABCONTROL, strlen(WC_TABCONTROL)+1)==0) /* Notebook */
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
375 {
191
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
376 NotebookPage **array = (NotebookPage **)dw_window_get_data(handle, "_dw_array");
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
377
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
378 if(array)
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
379 {
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
380 int z, refid = -1;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
381
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
382 for(z=0;z<256;z++)
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
383 {
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
384 if(array[z])
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
385 {
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
386 _free_window_memory(array[z]->hwnd, 0);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
387 EnumChildWindows(array[z]->hwnd, _free_window_memory, 0);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
388 DestroyWindow(array[z]->hwnd);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
389 free(array[z]);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
390 }
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
391 }
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
392 }
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
393 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
394
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
395 dw_signal_disconnect_by_window(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
396
82
aec9a0b0b539 Fixes for a resource leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 79
diff changeset
397 if(thiscinfo)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
398 {
180
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
399 SubclassWindow(handle, thiscinfo->pOldProc);
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
400
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
401 /* Delete the brush so as not to leak GDI objects */
82
aec9a0b0b539 Fixes for a resource leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 79
diff changeset
402 if(thiscinfo->hbrush)
aec9a0b0b539 Fixes for a resource leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 79
diff changeset
403 DeleteObject(thiscinfo->hbrush);
aec9a0b0b539 Fixes for a resource leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 79
diff changeset
404
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
405 /* Free user data linked list memory */
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
406 if(thiscinfo->root)
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
407 dw_window_set_data(handle, NULL, NULL);
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
408
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
409 SetWindowLong(handle, GWL_USERDATA, 0);
82
aec9a0b0b539 Fixes for a resource leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 79
diff changeset
410 free(thiscinfo);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
411 }
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
412 return TRUE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
413 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
414
191
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
415 /* Convert to our internal color scheme */
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
416 ULONG _internal_color(ULONG color)
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
417 {
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
418 if(color < 18)
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
419 return DW_RGB(_red[color], _green[color], _blue[color]);
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
420 return color;
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
421 }
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
422
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
423 /* This function returns 1 if the window (widget) handle
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
424 * passed to it is a valid window that can gain input focus.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
425 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
426 int _validate_focus(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
427 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
428 char tmpbuf[100];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
429
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
430 if(!handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
431 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
432
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
433 if(!IsWindowEnabled(handle))
39
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
434 return 0;
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
435
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
436 GetClassName(handle, tmpbuf, 99);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
437
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
438 /* These are the window classes which can
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
439 * obtain input focus.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
440 */
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
441 if(strnicmp(tmpbuf, EDITCLASSNAME, strlen(EDITCLASSNAME)+1)==0 || /* Entryfield */
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
442 strnicmp(tmpbuf, BUTTONCLASSNAME, strlen(BUTTONCLASSNAME)+1)==0 || /* Button */
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
443 strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0 || /* Combobox */
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
444 strnicmp(tmpbuf, LISTBOXCLASSNAME, strlen(LISTBOXCLASSNAME)+1)==0 || /* List box */
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
445 strnicmp(tmpbuf, UPDOWN_CLASS, strlen(UPDOWN_CLASS)+1)==0 || /* Spinbutton */
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
446 strnicmp(tmpbuf, TRACKBAR_CLASS, strlen(TRACKBAR_CLASS)+1)==0 || /* Slider */
68
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
447 strnicmp(tmpbuf, WC_LISTVIEW, strlen(WC_LISTVIEW)+1)== 0 || /* Container */
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
448 strnicmp(tmpbuf, WC_TREEVIEW, strlen(WC_TREEVIEW)+1)== 0) /* Tree */
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
449 return 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
450 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
451 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
452
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
453 HWND _normalize_handle(HWND handle)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
454 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
455 char tmpbuf[100] = "";
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
456
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
457 GetClassName(handle, tmpbuf, 99);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
458 if(strnicmp(tmpbuf, UPDOWN_CLASS, strlen(UPDOWN_CLASS))==0) /* Spinner */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
459 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
460 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
461
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
462 if(cinfo && cinfo->buddy)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
463 return cinfo->buddy;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
464 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
465 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME))==0) /* Combobox */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
466 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
467 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
468
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
469 if(cinfo && cinfo->buddy)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
470 return cinfo->buddy;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
471 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
472 return handle;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
473 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
474
34
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
475 int _focus_check_box(Box *box, HWND handle, int start, HWND defaultitem)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
476 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
477 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
478 static HWND lasthwnd, firsthwnd;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
479 static int finish_searching;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
480
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
481 /* Start is 2 when we have cycled completely and
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
482 * need to set the focus to the last widget we found
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
483 * that was valid.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
484 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
485 if(start == 2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
486 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
487 if(lasthwnd)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
488 SetFocus(lasthwnd);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
489 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
490 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
491
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
492 /* Start is 1 when we are entering the function
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
493 * for the first time, it is zero when entering
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
494 * the function recursively.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
495 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
496 if(start == 1)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
497 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
498 lasthwnd = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
499 finish_searching = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
500 firsthwnd = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
501 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
502
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
503 for(z=box->count-1;z>-1;z--)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
504 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
505 if(box->items[z].type == TYPEBOX)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
506 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
507 Box *thisbox = (Box *)GetWindowLong(box->items[z].hwnd, GWL_USERDATA);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
508
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
509 if(thisbox && _focus_check_box(thisbox, handle, start == 3 ? 3 : 0, defaultitem))
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
510 return 1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
511 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
512 else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
513 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
514 if(box->items[z].hwnd == handle)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
515 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
516 if(lasthwnd == handle && firsthwnd)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
517 SetFocus(firsthwnd);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
518 else if(lasthwnd == handle && !firsthwnd)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
519 finish_searching = 1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
520 else
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
521 SetFocus(lasthwnd);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
522
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
523 /* If we aren't looking for the last handle,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
524 * return immediately.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
525 */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
526 if(!finish_searching)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
527 return 1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
528 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
529 if(_validate_focus(box->items[z].hwnd))
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
530 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
531 /* Start is 3 when we are looking for the
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
532 * first valid item in the layout.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
533 */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
534 if(start == 3)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
535 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
536 if(!defaultitem || (defaultitem && box->items[z].hwnd == defaultitem))
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
537 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
538 SetFocus(_normalize_handle(box->items[z].hwnd));
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
539 return 1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
540 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
541 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
542
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
543 if(!firsthwnd)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
544 firsthwnd = _normalize_handle(box->items[z].hwnd);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
545
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
546 lasthwnd = _normalize_handle(box->items[z].hwnd);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
547 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
548 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
549 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
550 char tmpbuf[100] = "";
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
551
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
552 GetClassName(box->items[z].hwnd, tmpbuf, 99);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
553
153
a371875d5486 Sync up with the latest F/X sources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 151
diff changeset
554 if(strncmp(tmpbuf, SplitbarClassName, strlen(SplitbarClassName)+1)==0)
a371875d5486 Sync up with the latest F/X sources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 151
diff changeset
555 {
284
3431e445d831 Woops, screwed up the splitbar tab direction on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 283
diff changeset
556 /* Then try the bottom or right box */
3431e445d831 Woops, screwed up the splitbar tab direction on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 283
diff changeset
557 HWND mybox = (HWND)dw_window_get_data(box->items[z].hwnd, "_dw_bottomright");
153
a371875d5486 Sync up with the latest F/X sources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 151
diff changeset
558
a371875d5486 Sync up with the latest F/X sources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 151
diff changeset
559 if(mybox)
a371875d5486 Sync up with the latest F/X sources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 151
diff changeset
560 {
a371875d5486 Sync up with the latest F/X sources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 151
diff changeset
561 Box *splitbox = (Box *)GetWindowLong(mybox, GWL_USERDATA);
a371875d5486 Sync up with the latest F/X sources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 151
diff changeset
562
a371875d5486 Sync up with the latest F/X sources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 151
diff changeset
563 if(splitbox && _focus_check_box(splitbox, handle, start == 3 ? 3 : 0, defaultitem))
a371875d5486 Sync up with the latest F/X sources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 151
diff changeset
564 return 1;
a371875d5486 Sync up with the latest F/X sources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 151
diff changeset
565 }
a371875d5486 Sync up with the latest F/X sources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 151
diff changeset
566
284
3431e445d831 Woops, screwed up the splitbar tab direction on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 283
diff changeset
567 /* Try the top or left box */
3431e445d831 Woops, screwed up the splitbar tab direction on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 283
diff changeset
568 mybox = (HWND)dw_window_get_data(box->items[z].hwnd, "_dw_topleft");
153
a371875d5486 Sync up with the latest F/X sources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 151
diff changeset
569
a371875d5486 Sync up with the latest F/X sources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 151
diff changeset
570 if(mybox)
a371875d5486 Sync up with the latest F/X sources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 151
diff changeset
571 {
a371875d5486 Sync up with the latest F/X sources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 151
diff changeset
572 Box *splitbox = (Box *)GetWindowLong(mybox, GWL_USERDATA);
a371875d5486 Sync up with the latest F/X sources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 151
diff changeset
573
a371875d5486 Sync up with the latest F/X sources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 151
diff changeset
574 if(splitbox && _focus_check_box(splitbox, handle, start == 3 ? 3 : 0, defaultitem))
a371875d5486 Sync up with the latest F/X sources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 151
diff changeset
575 return 1;
a371875d5486 Sync up with the latest F/X sources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 151
diff changeset
576 }
a371875d5486 Sync up with the latest F/X sources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 151
diff changeset
577 }
a371875d5486 Sync up with the latest F/X sources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 151
diff changeset
578 else if(strnicmp(tmpbuf, WC_TABCONTROL, strlen(WC_TABCONTROL))==0) /* Notebook */
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
579 {
191
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
580 NotebookPage **array = (NotebookPage **)dw_window_get_data(box->items[z].hwnd, "_dw_array");
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
581 int pageid = TabCtrl_GetCurSel(box->items[z].hwnd);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
582
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
583 if(pageid > -1 && array && array[pageid])
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
584 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
585 Box *notebox;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
586
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
587 if(array[pageid]->hwnd)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
588 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
589 notebox = (Box *)GetWindowLong(array[pageid]->hwnd, GWL_USERDATA);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
590
34
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
591 if(notebox && _focus_check_box(notebox, handle, start == 3 ? 3 : 0, defaultitem))
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
592 return 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
593 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
594 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
595 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
596 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
597 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
598 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
599 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
600 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
601
61
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
602 int _focus_check_box_back(Box *box, HWND handle, int start, HWND defaultitem)
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
603 {
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
604 int z;
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
605 static HWND lasthwnd, firsthwnd;
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
606 static int finish_searching;
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
607
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
608 /* Start is 2 when we have cycled completely and
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
609 * need to set the focus to the last widget we found
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
610 * that was valid.
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
611 */
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
612 if(start == 2)
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
613 {
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
614 if(lasthwnd)
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
615 SetFocus(lasthwnd);
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
616 return 0;
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
617 }
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
618
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
619 /* Start is 1 when we are entering the function
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
620 * for the first time, it is zero when entering
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
621 * the function recursively.
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
622 */
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
623 if(start == 1)
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
624 {
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
625 lasthwnd = handle;
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
626 finish_searching = 0;
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
627 firsthwnd = 0;
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
628 }
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
629
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
630 for(z=0;z<box->count;z++)
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
631 {
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
632 if(box->items[z].type == TYPEBOX)
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
633 {
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
634 Box *thisbox = (Box *)GetWindowLong(box->items[z].hwnd, GWL_USERDATA);
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
635
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
636 if(thisbox && _focus_check_box_back(thisbox, handle, start == 3 ? 3 : 0, defaultitem))
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
637 return 1;
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
638 }
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
639 else
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
640 {
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
641 if(box->items[z].hwnd == handle)
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
642 {
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
643 if(lasthwnd == handle && firsthwnd)
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
644 SetFocus(firsthwnd);
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
645 else if(lasthwnd == handle && !firsthwnd)
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
646 finish_searching = 1;
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
647 else
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
648 SetFocus(lasthwnd);
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
649
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
650 /* If we aren't looking for the last handle,
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
651 * return immediately.
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
652 */
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
653 if(!finish_searching)
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
654 return 1;
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
655 }
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
656 if(_validate_focus(box->items[z].hwnd))
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
657 {
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
658 /* Start is 3 when we are looking for the
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
659 * first valid item in the layout.
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
660 */
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
661 if(start == 3)
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
662 {
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
663 if(!defaultitem || (defaultitem && box->items[z].hwnd == defaultitem))
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
664 {
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
665 SetFocus(_normalize_handle(box->items[z].hwnd));
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
666 return 1;
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
667 }
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
668 }
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
669
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
670 if(!firsthwnd)
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
671 firsthwnd = _normalize_handle(box->items[z].hwnd);
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
672
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
673 lasthwnd = _normalize_handle(box->items[z].hwnd);
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
674 }
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
675 else
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
676 {
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
677 char tmpbuf[100] = "";
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
678
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
679 GetClassName(box->items[z].hwnd, tmpbuf, 99);
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
680
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
681 if(strncmp(tmpbuf, SplitbarClassName, strlen(SplitbarClassName)+1)==0)
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
682 {
284
3431e445d831 Woops, screwed up the splitbar tab direction on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 283
diff changeset
683 /* Try the top or left box */
3431e445d831 Woops, screwed up the splitbar tab direction on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 283
diff changeset
684 HWND mybox = (HWND)dw_window_get_data(box->items[z].hwnd, "_dw_topleft");
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
685
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
686 if(mybox)
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
687 {
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
688 Box *splitbox = (Box *)GetWindowLong(mybox, GWL_USERDATA);
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
689
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
690 if(splitbox && _focus_check_box_back(splitbox, handle, start == 3 ? 3 : 0, defaultitem))
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
691 return 1;
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
692 }
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
693
284
3431e445d831 Woops, screwed up the splitbar tab direction on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 283
diff changeset
694 /* Then try the bottom or right box */
3431e445d831 Woops, screwed up the splitbar tab direction on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 283
diff changeset
695 mybox = (HWND)dw_window_get_data(box->items[z].hwnd, "_dw_bottomright");
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
696
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
697 if(mybox)
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
698 {
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
699 Box *splitbox = (Box *)GetWindowLong(mybox, GWL_USERDATA);
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
700
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
701 if(splitbox && _focus_check_box_back(splitbox, handle, start == 3 ? 3 : 0, defaultitem))
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
702 return 1;
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
703 }
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
704 }
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
705 else if(strnicmp(tmpbuf, WC_TABCONTROL, strlen(WC_TABCONTROL))==0) /* Notebook */
61
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
706 {
191
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
707 NotebookPage **array = (NotebookPage **)dw_window_get_data(box->items[z].hwnd, "_dw_array");
61
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
708 int pageid = TabCtrl_GetCurSel(box->items[z].hwnd);
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
709
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
710 if(pageid > -1 && array && array[pageid])
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
711 {
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
712 Box *notebox;
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
713
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
714 if(array[pageid]->hwnd)
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
715 {
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
716 notebox = (Box *)GetWindowLong(array[pageid]->hwnd, GWL_USERDATA);
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
717
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
718 if(notebox && _focus_check_box_back(notebox, handle, start == 3 ? 3 : 0, defaultitem))
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
719 return 1;
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
720 }
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
721 }
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
722 }
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
723 }
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
724 }
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
725 }
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
726 return 0;
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
727 }
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
728
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
729 /* This function finds the first widget in the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
730 * layout and moves the current focus to it.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
731 */
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
732 void _initial_focus(HWND handle)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
733 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
734 Box *thisbox;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
735 char tmpbuf[100];
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
736
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
737 if(!handle)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
738 return;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
739
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
740 GetClassName(handle, tmpbuf, 99);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
741
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
742 if(strnicmp(tmpbuf, ClassName, strlen(ClassName))!=0)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
743 return;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
744
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
745
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
746 if(handle)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
747 thisbox = (Box *)GetWindowLong(handle, GWL_USERDATA);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
748
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
749 if(thisbox)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
750 {
34
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
751 _focus_check_box(thisbox, handle, 3, thisbox->defaultitem);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
752 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
753 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
754
301
887675ee5b67 More keypress fixes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 299
diff changeset
755 HWND _toplevel_window(HWND handle)
887675ee5b67 More keypress fixes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 299
diff changeset
756 {
887675ee5b67 More keypress fixes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 299
diff changeset
757 HWND box, lastbox = GetParent(handle);
887675ee5b67 More keypress fixes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 299
diff changeset
758
887675ee5b67 More keypress fixes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 299
diff changeset
759 /* Find the toplevel window */
887675ee5b67 More keypress fixes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 299
diff changeset
760 while((box = GetParent(lastbox)))
887675ee5b67 More keypress fixes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 299
diff changeset
761 {
887675ee5b67 More keypress fixes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 299
diff changeset
762 lastbox = box;
887675ee5b67 More keypress fixes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 299
diff changeset
763 }
887675ee5b67 More keypress fixes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 299
diff changeset
764 if(lastbox)
887675ee5b67 More keypress fixes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 299
diff changeset
765 return lastbox;
887675ee5b67 More keypress fixes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 299
diff changeset
766 return handle;
887675ee5b67 More keypress fixes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 299
diff changeset
767 }
887675ee5b67 More keypress fixes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 299
diff changeset
768
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
769 /* This function finds the current widget in the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
770 * layout and moves the current focus to the next item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
771 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
772 void _shift_focus(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
773 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
774 Box *thisbox;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
775
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
776 HWND box, lastbox = GetParent(handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
777
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
778 /* Find the toplevel window */
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
779 while((box = GetParent(lastbox)))
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
780 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
781 lastbox = box;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
782 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
783
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
784 thisbox = (Box *)GetWindowLong(lastbox, GWL_USERDATA);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
785 if(thisbox)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
786 {
34
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
787 if(_focus_check_box(thisbox, handle, 1, 0) == 0)
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
788 _focus_check_box(thisbox, handle, 2, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
789 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
790 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
791
61
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
792 /* This function finds the current widget in the
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
793 * layout and moves the current focus to the next item.
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
794 */
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
795 void _shift_focus_back(HWND handle)
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
796 {
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
797 Box *thisbox;
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
798
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
799 HWND box, lastbox = GetParent(handle);
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
800
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
801 /* Find the toplevel window */
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
802 while((box = GetParent(lastbox)))
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
803 {
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
804 lastbox = box;
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
805 }
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
806
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
807 thisbox = (Box *)GetWindowLong(lastbox, GWL_USERDATA);
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
808 if(thisbox)
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
809 {
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
810 if(_focus_check_box_back(thisbox, handle, 1, 0) == 0)
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
811 _focus_check_box_back(thisbox, handle, 2, 0);
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
812 }
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
813 }
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
814
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
815 /* ResetWindow:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
816 * Resizes window to the exact same size to trigger
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
817 * recalculation of frame.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
818 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
819 void _ResetWindow(HWND hwndFrame)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
820 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
821 RECT rcl;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
822
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
823 GetWindowRect(hwndFrame, &rcl);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
824 SetWindowPos(hwndFrame, HWND_TOP, 0, 0, rcl.right - rcl.left,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
825 rcl.bottom - rcl.top - 1, SWP_NOMOVE | SWP_NOZORDER);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
826 SetWindowPos(hwndFrame, HWND_TOP, 0, 0, rcl.right - rcl.left,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
827 rcl.bottom - rcl.top, SWP_NOMOVE | SWP_NOZORDER);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
828 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
829
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
830 /* This function calculates how much space the widgets and boxes require
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
831 * and does expansion as necessary.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
832 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
833 int _resize_box(Box *thisbox, int *depth, int x, int y, int *usedx, int *usedy,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
834 int pass, int *usedpadx, int *usedpady)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
835 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
836 int z, currentx = 0, currenty = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
837 int uymax = 0, uxmax = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
838 int upymax = 0, upxmax = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
839 /* Used for the SIZEEXPAND */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
840 int nux = *usedx, nuy = *usedy;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
841 int nupx = *usedpadx, nupy = *usedpady;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
842
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
843 (*usedx) += (thisbox->pad * 2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
844 (*usedy) += (thisbox->pad * 2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
845
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
846 for(z=0;z<thisbox->count;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
847 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
848 if(thisbox->items[z].type == TYPEBOX)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
849 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
850 int initialx, initialy;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
851 Box *tmp = (Box *)GetWindowLong(thisbox->items[z].hwnd, GWL_USERDATA);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
852
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
853 initialx = x - (*usedx);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
854 initialy = y - (*usedy);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
855
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
856 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
857 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
858 int newx, newy;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
859 int nux = *usedx, nuy = *usedy;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
860 int upx = *usedpadx + (tmp->pad*2), upy = *usedpady + (tmp->pad*2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
861
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
862 /* On the second pass we know how big the box needs to be and how
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
863 * much space we have, so we can calculate a ratio for the new box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
864 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
865 if(pass == 2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
866 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
867 int deep = *depth + 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
868
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
869 _resize_box(tmp, &deep, x, y, &nux, &nuy, 1, &upx, &upy);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
870
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
871 tmp->upx = upx - *usedpadx;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
872 tmp->upy = upy - *usedpady;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
873
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
874 newx = x - nux;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
875 newy = y - nuy;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
876
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
877 tmp->width = thisbox->items[z].width = initialx - newx;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
878 tmp->height = thisbox->items[z].height = initialy - newy;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
879
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
880 tmp->parentxratio = thisbox->xratio;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
881 tmp->parentyratio = thisbox->yratio;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
882
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
883 tmp->parentpad = tmp->pad;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
884
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
885 /* Just in case */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
886 tmp->xratio = thisbox->xratio;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
887 tmp->yratio = thisbox->yratio;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
888
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
889 if(thisbox->type == DW_VERT)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
890 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
891 if((thisbox->items[z].width-((thisbox->items[z].pad*2)+(tmp->pad*2)))!=0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
892 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-((thisbox->items[z].pad*2)+(tmp->pad*2))))/((float)(thisbox->items[z].width-((thisbox->items[z].pad*2)+(tmp->pad*2))));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
893 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
894 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
895 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
896 if((thisbox->items[z].width-tmp->upx)!=0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
897 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-tmp->upx))/((float)(thisbox->items[z].width-tmp->upx));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
898 }
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
899 if(thisbox->type == DW_HORZ)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
900 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
901 if((thisbox->items[z].height-((thisbox->items[z].pad*2)+(tmp->pad*2)))!=0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
902 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-((thisbox->items[z].pad*2)+(tmp->pad*2))))/((float)(thisbox->items[z].height-((thisbox->items[z].pad*2)+(tmp->pad*2))));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
903 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
904 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
905 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
906 if((thisbox->items[z].height-tmp->upy)!=0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
907 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-tmp->upy))/((float)(thisbox->items[z].height-tmp->upy));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
908 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
909
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
910 nux = *usedx; nuy = *usedy;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
911 upx = *usedpadx + (tmp->pad*2); upy = *usedpady + (tmp->pad*2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
912 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
913
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
914 (*depth)++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
915
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
916 _resize_box(tmp, depth, x, y, &nux, &nuy, pass, &upx, &upy);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
917
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
918 (*depth)--;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
919
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
920 newx = x - nux;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
921 newy = y - nuy;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
922
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
923 tmp->minwidth = thisbox->items[z].width = initialx - newx;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
924 tmp->minheight = thisbox->items[z].height = initialy - newy;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
925 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
926 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
927
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
928 if(pass > 1 && *depth > 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
929 {
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
930 if(thisbox->type == DW_VERT)
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
931 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
932 if((thisbox->minwidth-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))) == 0)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
933 thisbox->items[z].xratio = 1.0;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
934 else
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
935 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))))/((float)(thisbox->minwidth-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))));
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
936 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
937 else
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
938 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
939 if(thisbox->minwidth-thisbox->upx == 0)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
940 thisbox->items[z].xratio = 1.0;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
941 else
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
942 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-thisbox->upx))/((float)(thisbox->minwidth-thisbox->upx));
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
943 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
944
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
945 if(thisbox->type == DW_HORZ)
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
946 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
947 if((thisbox->minheight-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))) == 0)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
948 thisbox->items[z].yratio = 1.0;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
949 else
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
950 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))))/((float)(thisbox->minheight-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))));
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
951 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
952 else
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
953 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
954 if(thisbox->minheight-thisbox->upy == 0)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
955 thisbox->items[z].yratio = 1.0;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
956 else
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
957 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-thisbox->upy))/((float)(thisbox->minheight-thisbox->upy));
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
958 }
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
959
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
960 if(thisbox->items[z].type == TYPEBOX)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
961 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
962 Box *tmp = (Box *)GetWindowLong(thisbox->items[z].hwnd, GWL_USERDATA);
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
963
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
964 if(tmp)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
965 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
966 tmp->parentxratio = thisbox->items[z].xratio;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
967 tmp->parentyratio = thisbox->items[z].yratio;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
968 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
969 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
970 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
971 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
972 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
973 thisbox->items[z].xratio = thisbox->xratio;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
974 thisbox->items[z].yratio = thisbox->yratio;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
975 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
976
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
977 if(thisbox->type == DW_VERT)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
978 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
979 if((thisbox->items[z].width + (thisbox->items[z].pad*2)) > uxmax)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
980 uxmax = (thisbox->items[z].width + (thisbox->items[z].pad*2));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
981 if(thisbox->items[z].hsize != SIZEEXPAND)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
982 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
983 if(((thisbox->items[z].pad*2) + thisbox->items[z].width) > upxmax)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
984 upxmax = (thisbox->items[z].pad*2) + thisbox->items[z].width;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
985 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
986 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
987 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
988 if(thisbox->items[z].pad*2 > upxmax)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
989 upxmax = thisbox->items[z].pad*2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
990 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
991 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
992 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
993 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
994 if(thisbox->items[z].width == -1)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
995 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
996 /* figure out how much space this item requires */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
997 /* thisbox->items[z].width = */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
998 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
999 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1000 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1001 (*usedx) += thisbox->items[z].width + (thisbox->items[z].pad*2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1002 if(thisbox->items[z].hsize != SIZEEXPAND)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1003 (*usedpadx) += (thisbox->items[z].pad*2) + thisbox->items[z].width;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1004 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1005 (*usedpadx) += thisbox->items[z].pad*2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1006 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1007 }
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
1008 if(thisbox->type == DW_HORZ)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1009 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1010 if((thisbox->items[z].height + (thisbox->items[z].pad*2)) > uymax)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1011 uymax = (thisbox->items[z].height + (thisbox->items[z].pad*2));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1012 if(thisbox->items[z].vsize != SIZEEXPAND)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1013 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1014 if(((thisbox->items[z].pad*2) + thisbox->items[z].height) > upymax)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1015 upymax = (thisbox->items[z].pad*2) + thisbox->items[z].height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1016 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1017 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1018 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1019 if(thisbox->items[z].pad*2 > upymax)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1020 upymax = thisbox->items[z].pad*2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1021 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1022 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1023 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1024 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1025 if(thisbox->items[z].height == -1)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1026 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1027 /* figure out how much space this item requires */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1028 /* thisbox->items[z].height = */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1029 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1030 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1031 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1032 (*usedy) += thisbox->items[z].height + (thisbox->items[z].pad*2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1033 if(thisbox->items[z].vsize != SIZEEXPAND)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1034 (*usedpady) += (thisbox->items[z].pad*2) + thisbox->items[z].height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1035 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1036 (*usedpady) += thisbox->items[z].pad*2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1037 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1038 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1039 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1040
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1041 (*usedx) += uxmax;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1042 (*usedy) += uymax;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1043 (*usedpadx) += upxmax;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1044 (*usedpady) += upymax;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1045
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1046 currentx += thisbox->pad;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1047 currenty += thisbox->pad;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1048
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1049 /* The second pass is for expansion and actual placement. */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1050 if(pass > 1)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1051 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1052 /* Any SIZEEXPAND items should be set to uxmax/uymax */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1053 for(z=0;z<thisbox->count;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1054 {
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
1055 if(thisbox->items[z].hsize == SIZEEXPAND && thisbox->type == DW_VERT)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1056 thisbox->items[z].width = uxmax-(thisbox->items[z].pad*2);
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
1057 if(thisbox->items[z].vsize == SIZEEXPAND && thisbox->type == DW_HORZ)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1058 thisbox->items[z].height = uymax-(thisbox->items[z].pad*2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1059 /* Run this code segment again to finalize the sized after setting uxmax/uymax values. */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1060 if(thisbox->items[z].type == TYPEBOX)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1061 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1062 Box *tmp = (Box *)GetWindowLong(thisbox->items[z].hwnd, GWL_USERDATA);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1063
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1064 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1065 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1066 if(*depth > 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1067 {
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
1068 if(thisbox->type == DW_VERT)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1069 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1070 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-((thisbox->items[z].pad*2)+(thisbox->pad*2))))/((float)(tmp->minwidth-((thisbox->items[z].pad*2)+(thisbox->pad*2))));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1071 tmp->width = thisbox->items[z].width;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1072 }
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
1073 if(thisbox->type == DW_HORZ)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1074 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1075 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-((thisbox->items[z].pad*2)+(thisbox->pad*2))))/((float)(tmp->minheight-((thisbox->items[z].pad*2)+(thisbox->pad*2))));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1076 tmp->height = thisbox->items[z].height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1077 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1078 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1079
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1080 (*depth)++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1081
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1082 _resize_box(tmp, depth, x, y, &nux, &nuy, 3, &nupx, &nupy);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1083
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1084 (*depth)--;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1085
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1086 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1087 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1088 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1089
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1090 for(z=0;z<(thisbox->count);z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1091 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1092 int height = thisbox->items[z].height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1093 int width = thisbox->items[z].width;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1094 int pad = thisbox->items[z].pad;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1095 HWND handle = thisbox->items[z].hwnd;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1096 int vectorx, vectory;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1097
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1098 /* When upxmax != pad*2 then ratios are incorrect. */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1099 vectorx = (int)((width*thisbox->items[z].xratio)-width);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1100 vectory = (int)((height*thisbox->items[z].yratio)-height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1101
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1102 if(width > 0 && height > 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1103 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1104 char tmpbuf[100];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1105 /* This is a hack to fix rounding of the sizing */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1106 if(*depth == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1107 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1108 vectorx++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1109 vectory++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1110 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1111
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1112 /* If this item isn't going to expand... reset the vectors to 0 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1113 if(thisbox->items[z].vsize != SIZEEXPAND)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1114 vectory = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1115 if(thisbox->items[z].hsize != SIZEEXPAND)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1116 vectorx = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1117
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1118 GetClassName(handle, tmpbuf, 99);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1119
88
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
1120 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1121 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1122 /* Handle special case Combobox */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1123 MoveWindow(handle, currentx + pad, currenty + pad,
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
1124 width + vectorx, (height + vectory) + 400, FALSE);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1125 }
88
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
1126 else if(strnicmp(tmpbuf, UPDOWN_CLASS, strlen(UPDOWN_CLASS)+1)==0)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1127 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1128 /* Handle special case Spinbutton */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1129 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1130
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1131 MoveWindow(handle, currentx + pad + ((width + vectorx) - 20), currenty + pad,
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
1132 20, height + vectory, FALSE);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1133
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1134 if(cinfo)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1135 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1136 MoveWindow(cinfo->buddy, currentx + pad, currenty + pad,
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
1137 (width + vectorx) - 20, height + vectory, FALSE);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1138 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1139 }
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
1140 else if(strncmp(tmpbuf, SplitbarClassName, strlen(SplitbarClassName)+1)==0)
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
1141 {
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
1142 /* Then try the bottom or right box */
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
1143 float *percent = (float *)dw_window_get_data(handle, "_dw_percent");
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
1144 int type = (int)dw_window_get_data(handle, "_dw_type");
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
1145 int cx = width + vectorx;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
1146 int cy = height + vectory;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
1147
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
1148 MoveWindow(handle, currentx + pad, currenty + pad,
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
1149 cx, cy, FALSE);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
1150
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
1151 if(cx > 0 && cy > 0 && percent)
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
1152 _handle_splitbar_resize(handle, *percent, type, cx, cy);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
1153 }
88
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
1154 else if(strnicmp(tmpbuf, STATICCLASSNAME, strlen(STATICCLASSNAME)+1)==0)
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
1155 {
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
1156 /* Handle special case Vertically Center static text */
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
1157 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA);
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
1158
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
1159 if(cinfo && cinfo->vcenter)
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
1160 {
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
1161 /* We are centered so calculate a new position */
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
1162 char tmpbuf[1024];
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
1163 int textheight, diff, total = height + vectory;
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
1164
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
1165 GetWindowText(handle, tmpbuf, 1023);
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
1166
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
1167 /* Figure out how big the text is */
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
1168 dw_font_text_extents(handle, 0, tmpbuf, 0, &textheight);
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
1169
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
1170 diff = (total - textheight) / 2;
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
1171
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
1172 MoveWindow(handle, currentx + pad, currenty + pad + diff,
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
1173 width + vectorx, height + vectory - diff, FALSE);
88
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
1174 }
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
1175 else
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
1176 {
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
1177 MoveWindow(handle, currentx + pad, currenty + pad,
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
1178 width + vectorx, height + vectory, FALSE);
88
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
1179 }
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
1180 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1181 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1182 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1183 /* Everything else */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1184 MoveWindow(handle, currentx + pad, currenty + pad,
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
1185 width + vectorx, height + vectory, FALSE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1186 if(thisbox->items[z].type == TYPEBOX)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1187 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1188 Box *boxinfo = (Box *)GetWindowLong(handle, GWL_USERDATA);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1189
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1190 if(boxinfo && boxinfo->grouphwnd)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1191 MoveWindow(boxinfo->grouphwnd, 0, 0,
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
1192 width + vectorx, height + vectory, FALSE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1193
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1194 }
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1195 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1196
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1197 /* Notebook dialog requires additional processing */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1198 if(strncmp(tmpbuf, WC_TABCONTROL, strlen(WC_TABCONTROL))==0)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1199 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1200 RECT rect;
191
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
1201 NotebookPage **array = (NotebookPage **)dw_window_get_data(handle, "_dw_array");
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1202 int pageid = TabCtrl_GetCurSel(handle);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1203
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1204 if(pageid > -1 && array && array[pageid])
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1205 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1206 GetClientRect(handle,&rect);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1207 TabCtrl_AdjustRect(handle,FALSE,&rect);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1208 MoveWindow(array[pageid]->hwnd, rect.left, rect.top,
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
1209 rect.right - rect.left, rect.bottom-rect.top, FALSE);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1210 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1211 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1212
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
1213 if(thisbox->type == DW_HORZ)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1214 currentx += width + vectorx + (pad * 2);
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
1215 if(thisbox->type == DW_VERT)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1216 currenty += height + vectory + (pad * 2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1217 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1218 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1219 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1220 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1221 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1222
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1223 void _do_resize(Box *thisbox, int x, int y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1224 {
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
1225 if(x != 0 && y != 0)
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
1226 {
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1227 if(thisbox)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1228 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1229 int usedx = 0, usedy = 0, depth = 0, usedpadx = 0, usedpady = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1230
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1231 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 1, &usedpadx, &usedpady);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1232
47
997e9ed670ef Fixes for box alignment problem on OS/2, crash in dw_bitmap_new() on unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 46
diff changeset
1233 if(usedx-usedpadx == 0 || usedy-usedpady == 0)
997e9ed670ef Fixes for box alignment problem on OS/2, crash in dw_bitmap_new() on unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 46
diff changeset
1234 return;
997e9ed670ef Fixes for box alignment problem on OS/2, crash in dw_bitmap_new() on unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 46
diff changeset
1235
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1236 thisbox->xratio = ((float)(x-usedpadx))/((float)(usedx-usedpadx));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1237 thisbox->yratio = ((float)(y-usedpady))/((float)(usedy-usedpady));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1238
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1239 usedpadx = usedpady = usedx = usedy = depth = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1240
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1241 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 2, &usedpadx, &usedpady);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1242 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1243 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1244 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1245
211
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1246 int _HandleScroller(HWND handle, int pos, int which)
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1247 {
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1248 SCROLLINFO si;
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1249
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1250 si.cbSize = sizeof(SCROLLINFO);
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1251 si.fMask = SIF_ALL;
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1252
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1253 SendMessage(handle, SBM_GETSCROLLINFO, 0, (LPARAM)&si);
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1254
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1255 switch(which)
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1256 {
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1257 case SB_THUMBTRACK:
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1258 return pos;
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1259 /*case SB_PAGEDOWN:*/
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1260 case SB_PAGELEFT:
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1261 pos = si.nPos - si.nPage;
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1262 if(pos < si.nMin)
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1263 pos = si.nMin;
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1264 return pos;
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1265 /*case SB_PAGEUP:*/
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1266 case SB_PAGERIGHT:
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1267 pos = si.nPos + si.nPage;
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1268 if(pos > (si.nMax - si.nPage) + 1)
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1269 pos = (si.nMax - si.nPage) + 1;
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1270 return pos;
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1271 /*case SB_LINEDOWN:*/
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1272 case SB_LINELEFT:
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1273 pos = si.nPos - 1;
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1274 if(pos < si.nMin)
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1275 pos = si.nMin;
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1276 return pos;
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1277 /*case SB_LINEUP:*/
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1278 case SB_LINERIGHT:
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1279 pos = si.nPos + 1;
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1280 if(pos > (si.nMax - si.nPage) + 1)
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1281 pos = (si.nMax - si.nPage) + 1;
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1282 return pos;
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1283 }
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1284 return -1;
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1285 }
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1286
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1287 /* The main window procedure for Dynamic Windows, all the resizing code is done here. */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1288 BOOL CALLBACK _wndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1289 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1290 int result = -1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1291 static int command_active = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1292 SignalHandler *tmp = Root;
182
b8caec82a4d2 Minor splitbar fixes on OS/2 and Windows. The splitbar width is now 4
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 181
diff changeset
1293 void (*windowfunc)(PVOID);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1294 ULONG origmsg = msg;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1295
295
aac3ab26d636 More key_press cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 294
diff changeset
1296 /* Deal with translating some messages */
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1297 if(msg == WM_RBUTTONDOWN || msg == WM_MBUTTONDOWN)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1298 msg = WM_LBUTTONDOWN;
295
aac3ab26d636 More key_press cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 294
diff changeset
1299 else if(msg == WM_RBUTTONUP || msg == WM_MBUTTONUP)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1300 msg = WM_LBUTTONUP;
295
aac3ab26d636 More key_press cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 294
diff changeset
1301 else if(msg == WM_HSCROLL)
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
1302 msg = WM_VSCROLL;
295
aac3ab26d636 More key_press cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 294
diff changeset
1303 else if(msg == WM_KEYDOWN && mp1 >= VK_F1 && mp1 <= VK_F24)
aac3ab26d636 More key_press cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 294
diff changeset
1304 msg = WM_CHAR;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1305
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1306 if(result == -1)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1307 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1308 /* Avoid infinite recursion */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1309 command_active = 1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1310
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1311 /* Find any callbacks for this function */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1312 while(tmp)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1313 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1314 if(tmp->message == msg || msg == WM_COMMAND || msg == WM_NOTIFY || tmp->message == WM_USER+1)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1315 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1316 switch(msg)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1317 {
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
1318 case WM_TIMER:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
1319 {
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
1320 int (*timerfunc)(void *) = tmp->signalfunction;
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
1321 if(tmp->id == (int)mp1)
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
1322 {
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
1323 if(!timerfunc(tmp->data))
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
1324 dw_timer_disconnect(tmp->id);
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
1325 tmp = NULL;
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
1326 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
1327 result = 0;
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
1328 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
1329 break;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1330 case WM_SETFOCUS:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1331 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1332 int (*setfocusfunc)(HWND, void *) = (int (*)(HWND, void *))tmp->signalfunction;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1333
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1334 if(hWnd == tmp->window)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1335 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1336 result = setfocusfunc(tmp->window, tmp->data);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1337 tmp = NULL;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1338 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1339 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1340 break;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1341 case WM_SIZE:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1342 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1343 int (*sizefunc)(HWND, int, int, void *) = tmp->signalfunction;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1344
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1345 if(hWnd == tmp->window)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1346 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1347 result = sizefunc(tmp->window, LOWORD(mp2), HIWORD(mp2), tmp->data);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1348 tmp = NULL;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1349 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1350 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1351 break;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1352 case WM_LBUTTONDOWN:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1353 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1354 POINTS pts = MAKEPOINTS(mp2);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1355 int (*buttonfunc)(HWND, int, int, int, void *) = (int (*)(HWND, int, int, int, void *))tmp->signalfunction;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1356
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1357 if(hWnd == tmp->window)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1358 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1359 int button;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1360
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1361 switch(origmsg)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1362 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1363 case WM_LBUTTONDOWN:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1364 button = 1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1365 break;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1366 case WM_RBUTTONDOWN:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1367 button = 2;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1368 break;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1369 case WM_MBUTTONDOWN:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1370 button = 3;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1371 break;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1372 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1373 result = buttonfunc(tmp->window, pts.x, pts.y, button, tmp->data);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1374 tmp = NULL;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1375 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1376 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1377 break;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1378 case WM_LBUTTONUP:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1379 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1380 POINTS pts = MAKEPOINTS(mp2);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1381 int (*buttonfunc)(HWND, int, int, int, void *) = (int (*)(HWND, int, int, int, void *))tmp->signalfunction;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1382
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1383 if(hWnd == tmp->window)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1384 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1385 int button;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1386
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1387 switch(origmsg)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1388 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1389 case WM_LBUTTONUP:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1390 button = 1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1391 break;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1392 case WM_RBUTTONUP:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1393 button = 2;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1394 break;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1395 case WM_MBUTTONUP:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1396 button = 3;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1397 break;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1398 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1399 result = buttonfunc(tmp->window, pts.x, pts.y, button, tmp->data);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1400 tmp = NULL;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1401 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1402 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1403 break;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1404 case WM_MOUSEMOVE:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1405 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1406 POINTS pts = MAKEPOINTS(mp2);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1407 int (*motionfunc)(HWND, int, int, int, void *) = (int (*)(HWND, int, int, int, void *))tmp->signalfunction;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1408
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1409 if(hWnd == tmp->window)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1410 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1411 int keys = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1412
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1413 if (mp1 & MK_LBUTTON)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1414 keys = DW_BUTTON1_MASK;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1415 if (mp1 & MK_RBUTTON)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1416 keys |= DW_BUTTON2_MASK;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1417 if (mp1 & MK_MBUTTON)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1418 keys |= DW_BUTTON3_MASK;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1419
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1420 result = motionfunc(tmp->window, pts.x, pts.y, keys, tmp->data);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1421 tmp = NULL;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1422 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1423 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1424 break;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1425 case WM_CHAR:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1426 {
267
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1427 int (*keypressfunc)(HWND, char, int, int, void *) = tmp->signalfunction;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1428
301
887675ee5b67 More keypress fixes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 299
diff changeset
1429 if(hWnd == tmp->window || _toplevel_window(hWnd) == tmp->window)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1430 {
267
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1431 int special = 0;
295
aac3ab26d636 More key_press cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 294
diff changeset
1432 char ch = 0;
267
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1433
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1434 if(GetAsyncKeyState(VK_SHIFT) & 0x8000)
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1435 special |= KC_SHIFT;
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1436 if(GetAsyncKeyState(VK_CONTROL) & 0x8000)
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1437 special |= KC_CTRL;
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1438 if(mp2 & (1 << 29))
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1439 special |= KC_ALT;
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1440
295
aac3ab26d636 More key_press cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 294
diff changeset
1441 if(origmsg == WM_CHAR && mp1 < 128)
aac3ab26d636 More key_press cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 294
diff changeset
1442 ch = (char)mp1;
aac3ab26d636 More key_press cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 294
diff changeset
1443
aac3ab26d636 More key_press cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 294
diff changeset
1444 result = keypressfunc(tmp->window, ch, mp1, special, tmp->data);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1445 tmp = NULL;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1446 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1447 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1448 break;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1449 case WM_CLOSE:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1450 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1451 int (*closefunc)(HWND, void *) = tmp->signalfunction;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1452
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1453 if(hWnd == tmp->window)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1454 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1455 result = closefunc(tmp->window, tmp->data);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1456 tmp = NULL;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1457 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1458 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1459 break;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1460 case WM_PAINT:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1461 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1462 PAINTSTRUCT ps;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1463 DWExpose exp;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1464 int (*exposefunc)(HWND, DWExpose *, void *) = tmp->signalfunction;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1465
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1466 if(hWnd == tmp->window)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1467 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1468 BeginPaint(hWnd, &ps);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1469 exp.x = ps.rcPaint.left;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1470 exp.y = ps.rcPaint.top;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1471 exp.width = ps.rcPaint.right - ps.rcPaint.left;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1472 exp.height = ps.rcPaint.bottom - ps.rcPaint.top;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1473 result = exposefunc(hWnd, &exp, tmp->data);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1474 EndPaint(hWnd, &ps);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1475 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1476 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1477 break;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1478 case WM_NOTIFY:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1479 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1480 if(tmp->message == TVN_SELCHANGED || tmp->message == NM_RCLICK)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1481 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1482 NMTREEVIEW FAR *tem=(NMTREEVIEW FAR *)mp2;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1483 char tmpbuf[100];
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1484
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1485 GetClassName(tem->hdr.hwndFrom, tmpbuf, 99);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1486
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1487 if(strnicmp(tmpbuf, WC_TREEVIEW, strlen(WC_TREEVIEW))==0)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1488 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1489 if(tem->hdr.code == TVN_SELCHANGED && tmp->message == TVN_SELCHANGED)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1490 {
321
be76b984620a Make sure dw_tree_item_select() does not cause a DW_SIGNAL_ITEM_SELECT.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 318
diff changeset
1491 if(tmp->window == tem->hdr.hwndFrom && !dw_window_get_data(tmp->window, "_dw_select_item"))
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1492 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1493 int (*treeselectfunc)(HWND, HWND, char *, void *, void *) = tmp->signalfunction;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1494 TVITEM tvi;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1495 void **ptrs;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1496
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1497 tvi.mask = TVIF_HANDLE;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1498 tvi.hItem = tem->itemNew.hItem;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1499
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1500 TreeView_GetItem(tmp->window, &tvi);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1501
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1502 ptrs = (void **)tvi.lParam;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1503 if(ptrs)
311
24c1dfffe97e Unified the callback functions for tree and container widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 310
diff changeset
1504 result = treeselectfunc(tmp->window, (HWND)tem->itemNew.hItem, (char *)ptrs[0], tmp->data, (void *)ptrs[1]);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1505
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1506 tmp = NULL;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1507 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1508 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1509 else if(tem->hdr.code == NM_RCLICK && tmp->message == NM_RCLICK)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1510 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1511 if(tmp->window == tem->hdr.hwndFrom)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1512 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1513 int (*containercontextfunc)(HWND, char *, int, int, void *, void *) = tmp->signalfunction;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1514 HTREEITEM hti;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1515 TVITEM tvi;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1516 TVHITTESTINFO thi;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1517 void **ptrs = NULL;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1518 LONG x, y;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1519
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1520 dw_pointer_query_pos(&x, &y);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1521
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1522 thi.pt.x = x;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1523 thi.pt.y = y;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1524
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1525 MapWindowPoints(HWND_DESKTOP, tmp->window, &thi.pt, 1);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1526
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1527 hti = TreeView_HitTest(tmp->window, &thi);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1528
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1529 if(hti)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1530 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1531 tvi.mask = TVIF_HANDLE;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1532 tvi.hItem = hti;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1533
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1534 TreeView_GetItem(tmp->window, &tvi);
328
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 321
diff changeset
1535 dw_tree_item_select(tmp->window, hti);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1536
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1537 ptrs = (void **)tvi.lParam;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1538
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1539 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1540 containercontextfunc(tmp->window, ptrs ? (char *)ptrs[0] : NULL, x, y, tmp->data, ptrs ? ptrs[1] : NULL);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1541 tmp = NULL;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1542 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1543 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1544 }
161
c555d06b6c93 Allow tree-select signal to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
1545 else if(strnicmp(tmpbuf, WC_LISTVIEW, strlen(WC_LISTVIEW)+1)==0)
c555d06b6c93 Allow tree-select signal to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
1546 {
c555d06b6c93 Allow tree-select signal to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
1547 if(tem->hdr.code == LVN_ITEMCHANGED && tmp->message == TVN_SELCHANGED)
c555d06b6c93 Allow tree-select signal to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
1548 {
c555d06b6c93 Allow tree-select signal to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
1549 if(tmp->window == tem->hdr.hwndFrom)
c555d06b6c93 Allow tree-select signal to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
1550 {
c555d06b6c93 Allow tree-select signal to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
1551 LV_ITEM lvi;
c555d06b6c93 Allow tree-select signal to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
1552 int iItem;
c555d06b6c93 Allow tree-select signal to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
1553
c555d06b6c93 Allow tree-select signal to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
1554 iItem = ListView_GetNextItem(tmp->window, -1, LVNI_FOCUSED);
c555d06b6c93 Allow tree-select signal to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
1555
c555d06b6c93 Allow tree-select signal to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
1556 memset(&lvi, 0, sizeof(LV_ITEM));
c555d06b6c93 Allow tree-select signal to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
1557
c555d06b6c93 Allow tree-select signal to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
1558 if(iItem > -1)
c555d06b6c93 Allow tree-select signal to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
1559 {
311
24c1dfffe97e Unified the callback functions for tree and container widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 310
diff changeset
1560 int (*treeselectfunc)(HWND, HWND, char *, void *, void *) = tmp->signalfunction;
161
c555d06b6c93 Allow tree-select signal to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
1561
c555d06b6c93 Allow tree-select signal to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
1562 lvi.iItem = iItem;
c555d06b6c93 Allow tree-select signal to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
1563 lvi.mask = LVIF_PARAM;
c555d06b6c93 Allow tree-select signal to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
1564
c555d06b6c93 Allow tree-select signal to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
1565 ListView_GetItem(tmp->window, &lvi);
c555d06b6c93 Allow tree-select signal to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
1566
c555d06b6c93 Allow tree-select signal to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
1567 /* Seems to be having lParam as 1 which really sucks */
c555d06b6c93 Allow tree-select signal to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
1568 if(lvi.lParam < 100)
c555d06b6c93 Allow tree-select signal to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
1569 lvi.lParam = 0;
c555d06b6c93 Allow tree-select signal to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
1570
311
24c1dfffe97e Unified the callback functions for tree and container widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 310
diff changeset
1571 treeselectfunc(tmp->window, 0, (char *)lvi.lParam, tmp->data, 0);
161
c555d06b6c93 Allow tree-select signal to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
1572 tmp = NULL;
c555d06b6c93 Allow tree-select signal to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
1573 }
c555d06b6c93 Allow tree-select signal to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
1574 }
c555d06b6c93 Allow tree-select signal to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
1575 }
c555d06b6c93 Allow tree-select signal to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
1576 }
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1577 }
332
7b0f00729a32 Implement switch-page signal for notebooks. Bit of a bug in that it fires
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 328
diff changeset
1578 else if(tmp->message == TCN_SELCHANGE)
7b0f00729a32 Implement switch-page signal for notebooks. Bit of a bug in that it fires
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 328
diff changeset
1579 {
7b0f00729a32 Implement switch-page signal for notebooks. Bit of a bug in that it fires
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 328
diff changeset
1580 NMHDR FAR *tem=(NMHDR FAR *)mp2;
334
0a15a1f3fbed Check that the notification message is actually TCN_SELCHANGE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 332
diff changeset
1581 if(tmp->window == tem->hwndFrom && tem->code == tmp->message)
332
7b0f00729a32 Implement switch-page signal for notebooks. Bit of a bug in that it fires
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 328
diff changeset
1582 {
7b0f00729a32 Implement switch-page signal for notebooks. Bit of a bug in that it fires
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 328
diff changeset
1583 int (*switchpagefunc)(HWND, int, void *) = tmp->signalfunction;
7b0f00729a32 Implement switch-page signal for notebooks. Bit of a bug in that it fires
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 328
diff changeset
1584 int num=TabCtrl_GetCurSel(tem->hwndFrom);
7b0f00729a32 Implement switch-page signal for notebooks. Bit of a bug in that it fires
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 328
diff changeset
1585 result = switchpagefunc(tem->hwndFrom, num, tmp->data);
7b0f00729a32 Implement switch-page signal for notebooks. Bit of a bug in that it fires
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 328
diff changeset
1586 }
7b0f00729a32 Implement switch-page signal for notebooks. Bit of a bug in that it fires
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 328
diff changeset
1587 }
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1588 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1589 break;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1590 case WM_COMMAND:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1591 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1592 int (*clickfunc)(HWND, void *) = tmp->signalfunction;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1593 HWND command;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1594 ULONG passthru = (ULONG)LOWORD(mp1);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1595 ULONG message = HIWORD(mp1);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1596
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1597 command = (HWND)passthru;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1598
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1599 if(message == LBN_SELCHANGE || message == CBN_SELCHANGE)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1600 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1601 int (*listboxselectfunc)(HWND, int, void *) = tmp->signalfunction;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1602
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1603 if(tmp->message == LBN_SELCHANGE && tmp->window == (HWND)mp2)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1604 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1605 result = listboxselectfunc(tmp->window, dw_listbox_selected(tmp->window), tmp->data);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1606 tmp = NULL;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1607 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1608 } /* Make sure it's the right window, and the right ID */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1609 else if(tmp->window < (HWND)65536 && command == tmp->window)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1610 {
93
98cce029a611 Changed handling of menu item click events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 90
diff changeset
1611 result = clickfunc(popup ? popup : tmp->window, tmp->data);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1612 tmp = NULL;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1613 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1614 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1615 break;
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
1616 case WM_HSCROLL:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
1617 case WM_VSCROLL:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
1618 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
1619 char tmpbuf[100];
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
1620 HWND handle = (HWND)mp2;
204
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
1621 int (*valuechangefunc)(HWND, int, void *) = tmp->signalfunction;
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
1622
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
1623 GetClassName(handle, tmpbuf, 99);
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
1624
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
1625 if(strnicmp(tmpbuf, TRACKBAR_CLASS, strlen(TRACKBAR_CLASS)+1)==0)
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
1626 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
1627
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
1628 if(handle == tmp->window)
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
1629 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
1630 int value = (int)SendMessage(handle, TBM_GETPOS, 0, 0);
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
1631 int max = (int)SendMessage(handle, TBM_GETRANGEMAX, 0, 0);
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
1632 ULONG currentstyle = GetWindowLong(handle, GWL_STYLE);
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
1633
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
1634 if(currentstyle & TBS_VERT)
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
1635 result = valuechangefunc(tmp->window, max - value, tmp->data);
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
1636 else
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
1637 result = valuechangefunc(tmp->window, value, tmp->data);
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
1638 tmp = NULL;
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
1639 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
1640 }
204
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
1641 else if(strnicmp(tmpbuf, SCROLLBARCLASSNAME, strlen(SCROLLBARCLASSNAME)+1)==0)
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
1642 {
211
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1643 if(handle == tmp->window)
204
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
1644 {
211
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1645 int value = _HandleScroller(handle, (int)HIWORD(mp1), (int)LOWORD(mp1));
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1646
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1647 if(value > -1)
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1648 {
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1649 dw_scrollbar_set_pos(tmp->window, value);
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1650 result = valuechangefunc(tmp->window, value, tmp->data);
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1651 }
204
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
1652 tmp = NULL;
211
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1653 msg = 0;
204
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
1654 }
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
1655 }
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
1656 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
1657 break;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1658 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1659 }
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1660 if(tmp)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1661 tmp = tmp->next;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1662 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1663 command_active = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1664 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1665
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1666 /* Now that any handlers are done... do normal processing */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1667 switch( msg )
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1668 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1669 case WM_PAINT:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1670 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1671 PAINTSTRUCT ps;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1672
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1673 BeginPaint(hWnd, &ps);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1674 EndPaint(hWnd, &ps);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1675 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1676 break;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1677 case WM_SIZE:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1678 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1679 static int lastx = -1, lasty = -1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1680 static HWND lasthwnd = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1681
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1682 if(lastx != LOWORD(mp2) || lasty != HIWORD(mp2) || lasthwnd != hWnd)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1683 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1684 Box *mybox = (Box *)GetWindowLong(hWnd, GWL_USERDATA);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1685
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1686 if(mybox && mybox->count)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1687 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1688 lastx = LOWORD(mp2);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1689 lasty = HIWORD(mp2);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1690 lasthwnd = hWnd;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1691
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1692 ShowWindow(mybox->items[0].hwnd, SW_HIDE);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1693 _do_resize(mybox,LOWORD(mp2),HIWORD(mp2));
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1694 ShowWindow(mybox->items[0].hwnd, SW_SHOW);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1695 return 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1696 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1697 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1698 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1699 break;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1700 case WM_CHAR:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1701 if(LOWORD(mp1) == '\t')
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1702 {
82
aec9a0b0b539 Fixes for a resource leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 79
diff changeset
1703 if(GetAsyncKeyState(VK_SHIFT) & 0x8000)
61
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
1704 _shift_focus_back(hWnd);
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
1705 else
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
1706 _shift_focus(hWnd);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1707 return TRUE;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1708 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1709 break;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1710 case WM_USER:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1711 windowfunc = (void *)mp1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1712
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1713 if(windowfunc)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1714 windowfunc((void *)mp2);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1715 break;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1716 case WM_NOTIFY:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1717 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1718 NMHDR FAR *tem=(NMHDR FAR *)mp2;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1719
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1720 if(tem->code == TCN_SELCHANGING)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1721 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1722 int num=TabCtrl_GetCurSel(tem->hwndFrom);
191
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
1723 NotebookPage **array = (NotebookPage **)dw_window_get_data(tem->hwndFrom, "_dw_array");
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1724
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1725 if(num > -1 && array && array[num])
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1726 SetParent(array[num]->hwnd, DW_HWND_OBJECT);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1727
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1728 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1729 else if(tem->code == TCN_SELCHANGE)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1730 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1731 int num=TabCtrl_GetCurSel(tem->hwndFrom);
191
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
1732 NotebookPage **array = (NotebookPage **)dw_window_get_data(tem->hwndFrom, "_dw_array");
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1733
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1734 if(num > -1 && array && array[num])
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1735 SetParent(array[num]->hwnd, tem->hwndFrom);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1736
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1737 _resize_notebook_page(tem->hwndFrom, num);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1738 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1739 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1740 break;
204
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
1741 case WM_HSCROLL:
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
1742 case WM_VSCROLL:
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
1743 {
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
1744 HWND handle = (HWND)mp2;
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
1745
211
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1746 if(dw_window_get_data(handle, "_dw_scrollbar"))
204
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
1747 {
211
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1748 int value = _HandleScroller(handle, (int)HIWORD(mp1), (int)LOWORD(mp1));
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1749
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1750 if(value > -1)
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1751 dw_scrollbar_set_pos(handle, value);
204
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
1752 }
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
1753 }
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
1754 break;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1755 case WM_GETMINMAXINFO:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1756 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1757 MINMAXINFO *info = (MINMAXINFO *)mp2;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1758 info->ptMinTrackSize.x = 8;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1759 info->ptMinTrackSize.y = 8;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1760 return 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1761 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1762 break;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1763 case WM_DESTROY:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1764 /* Free memory before destroying */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1765 _free_window_memory(hWnd, 0);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1766 EnumChildWindows(hWnd, _free_window_memory, 0);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1767 break;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1768 case WM_CTLCOLORSTATIC:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1769 case WM_CTLCOLORLISTBOX:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1770 case WM_CTLCOLORBTN:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1771 case WM_CTLCOLOREDIT:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1772 case WM_CTLCOLORMSGBOX:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1773 case WM_CTLCOLORSCROLLBAR:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1774 case WM_CTLCOLORDLG:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1775 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1776 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLong((HWND)mp2, GWL_USERDATA);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1777 if(thiscinfo && thiscinfo->fore != -1 && thiscinfo->back != -1)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1778 {
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1779 /* Handle foreground */
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1780 if(thiscinfo->fore > -1 && thiscinfo->fore < 18)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1781 {
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1782 if(thiscinfo->fore != DW_CLR_DEFAULT)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1783 {
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1784 SetTextColor((HDC)mp1, RGB(_red[thiscinfo->fore],
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1785 _green[thiscinfo->fore],
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1786 _blue[thiscinfo->fore]));
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1787 }
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1788 }
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1789 else if((thiscinfo->fore & DW_RGB_COLOR) == DW_RGB_COLOR)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1790 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1791 SetTextColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->fore),
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1792 DW_GREEN_VALUE(thiscinfo->fore),
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1793 DW_BLUE_VALUE(thiscinfo->fore)));
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1794 }
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1795 /* Handle background */
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1796 if(thiscinfo->back > -1 && thiscinfo->back < 18)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1797 {
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1798 if(thiscinfo->back == DW_CLR_DEFAULT)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1799 {
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1800 HBRUSH hbr = GetSysColorBrush(COLOR_3DFACE);
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1801
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1802 SelectObject((HDC)mp1, hbr);
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1803 return (LONG)hbr;
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1804 }
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1805 else
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1806 {
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1807 SetBkColor((HDC)mp1, RGB(_red[thiscinfo->back],
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1808 _green[thiscinfo->back],
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1809 _blue[thiscinfo->back]));
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1810 if(thiscinfo->hbrush)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1811 DeleteObject(thiscinfo->hbrush);
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1812 thiscinfo->hbrush = CreateSolidBrush(RGB(_red[thiscinfo->back],
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1813 _green[thiscinfo->back],
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1814 _blue[thiscinfo->back]));
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1815 SelectObject((HDC)mp1, thiscinfo->hbrush);
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1816 }
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1817 return (LONG)thiscinfo->hbrush;
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1818 }
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1819 else if((thiscinfo->back & DW_RGB_COLOR) == DW_RGB_COLOR)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1820 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1821 SetBkColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->back),
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1822 DW_GREEN_VALUE(thiscinfo->back),
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1823 DW_BLUE_VALUE(thiscinfo->back)));
82
aec9a0b0b539 Fixes for a resource leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 79
diff changeset
1824 if(thiscinfo->hbrush)
aec9a0b0b539 Fixes for a resource leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 79
diff changeset
1825 DeleteObject(thiscinfo->hbrush);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1826 thiscinfo->hbrush = CreateSolidBrush(RGB(DW_RED_VALUE(thiscinfo->back),
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1827 DW_GREEN_VALUE(thiscinfo->back),
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1828 DW_BLUE_VALUE(thiscinfo->back)));
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1829 SelectObject((HDC)mp1, thiscinfo->hbrush);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1830 return (LONG)thiscinfo->hbrush;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1831 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1832 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1833
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1834 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1835 break;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1836 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1837 if(result != -1)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1838 return result;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1839 else
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1840 return DefWindowProc(hWnd, msg, mp1, mp2);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1841 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1842
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1843 BOOL CALLBACK _framewndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1844 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1845 switch( msg )
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1846 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1847 case WM_LBUTTONDOWN:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1848 case WM_MBUTTONDOWN:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1849 case WM_RBUTTONDOWN:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1850 SetActiveWindow(hWnd);
106
4b6799f3dbbc Give the frame window focus if it is clicked on.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 105
diff changeset
1851 SetFocus(hWnd);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1852 break;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1853 case WM_COMMAND:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1854 case WM_NOTIFY:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1855 _wndproc(hWnd, msg, mp1, mp2);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1856 break;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1857 #if 0
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1858 case WM_ERASEBKGND:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1859 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1860 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLong(hWnd, GWL_USERDATA);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1861
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1862 if(thiscinfo && thiscinfo->fore != -1 && thiscinfo->back != -1)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1863 return FALSE;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1864 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1865 break;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1866 #endif
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1867 case WM_PAINT:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1868 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1869 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLong(hWnd, GWL_USERDATA);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1870
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1871 if(thiscinfo && thiscinfo->fore != -1 && thiscinfo->back != -1)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1872 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1873 PAINTSTRUCT ps;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1874 HDC hdcPaint = BeginPaint(hWnd, &ps);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1875 int success = FALSE;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1876
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1877 if(thiscinfo && thiscinfo->fore != -1 && thiscinfo->back != -1)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1878 {
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1879 /* Handle foreground */
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1880 if(thiscinfo->fore > -1 && thiscinfo->fore < 18)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1881 {
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1882 if(thiscinfo->fore != DW_CLR_DEFAULT)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1883 {
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1884 SetTextColor((HDC)mp1, RGB(_red[thiscinfo->fore],
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1885 _green[thiscinfo->fore],
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1886 _blue[thiscinfo->fore]));
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1887 }
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1888 }
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1889 else if((thiscinfo->fore & DW_RGB_COLOR) == DW_RGB_COLOR)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1890 {
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1891 SetTextColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->fore),
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1892 DW_GREEN_VALUE(thiscinfo->fore),
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1893 DW_BLUE_VALUE(thiscinfo->fore)));
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1894 }
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1895 /* Handle background */
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1896 if(thiscinfo->back > -1 && thiscinfo->back < 18)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1897 {
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1898 if(thiscinfo->back != DW_CLR_DEFAULT)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1899 {
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1900 SetBkColor((HDC)mp1, RGB(_red[thiscinfo->back],
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1901 _green[thiscinfo->back],
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1902 _blue[thiscinfo->back]));
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1903 if(thiscinfo->hbrush)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1904 DeleteObject(thiscinfo->hbrush);
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1905 thiscinfo->hbrush = CreateSolidBrush(RGB(_red[thiscinfo->back],
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1906 _green[thiscinfo->back],
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1907 _blue[thiscinfo->back]));
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1908 SelectObject(hdcPaint, thiscinfo->hbrush);
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1909 Rectangle(hdcPaint, ps.rcPaint.left - 1, ps.rcPaint.top - 1, ps.rcPaint.right + 1, ps.rcPaint.bottom + 1);
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1910 success = TRUE;
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1911 }
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1912 }
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1913 else if((thiscinfo->back & DW_RGB_COLOR) == DW_RGB_COLOR)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1914 {
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1915 SetBkColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->back),
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1916 DW_GREEN_VALUE(thiscinfo->back),
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1917 DW_BLUE_VALUE(thiscinfo->back)));
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1918 if(thiscinfo->hbrush)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1919 DeleteObject(thiscinfo->hbrush);
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1920 thiscinfo->hbrush = CreateSolidBrush(RGB(DW_RED_VALUE(thiscinfo->back),
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1921 DW_GREEN_VALUE(thiscinfo->back),
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1922 DW_BLUE_VALUE(thiscinfo->back)));
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1923 SelectObject(hdcPaint, thiscinfo->hbrush);
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1924 Rectangle(hdcPaint, ps.rcPaint.left - 1, ps.rcPaint.top - 1, ps.rcPaint.right + 1, ps.rcPaint.bottom + 1);
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1925 success = TRUE;
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1926 }
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1927 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1928
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1929 EndPaint(hWnd, &ps);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1930 if(success)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1931 return FALSE;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1932 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1933
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1934 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1935 break;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1936 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1937 return DefWindowProc(hWnd, msg, mp1, mp2);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1938 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1939
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1940 BOOL CALLBACK _rendwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1941 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1942 switch( msg )
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1943 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1944 case WM_LBUTTONDOWN:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1945 case WM_MBUTTONDOWN:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1946 case WM_RBUTTONDOWN:
267
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1947 SetFocus(hWnd);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1948 _wndproc(hWnd, msg, mp1, mp2);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1949 break;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1950 case WM_LBUTTONUP:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1951 case WM_MBUTTONUP:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1952 case WM_RBUTTONUP:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1953 case WM_MOUSEMOVE:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1954 case WM_PAINT:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1955 case WM_SIZE:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1956 case WM_COMMAND:
267
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1957 case WM_CHAR:
295
aac3ab26d636 More key_press cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 294
diff changeset
1958 case WM_KEYDOWN:
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1959 _wndproc(hWnd, msg, mp1, mp2);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1960 break;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1961 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1962 return DefWindowProc(hWnd, msg, mp1, mp2);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1963 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1964
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1965 BOOL CALLBACK _spinnerwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1966 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1967 ColorInfo *cinfo;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1968
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1969 cinfo = (ColorInfo *)GetWindowLong(hWnd, GWL_USERDATA);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1970
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1971 if(cinfo)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1972 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1973 switch( msg )
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1974 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1975 case WM_LBUTTONDOWN:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1976 case WM_MBUTTONDOWN:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1977 case WM_RBUTTONDOWN:
109
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
1978 case WM_KEYDOWN:
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1979 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1980 BOOL ret;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1981
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1982 if(!cinfo || !cinfo->pOldProc)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1983 ret = DefWindowProc(hWnd, msg, mp1, mp2);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1984 ret = CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1985
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1986 /* Tell the edit control that a buttonpress has
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1987 * occured and to update it's window title.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1988 */
109
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
1989 if(cinfo && cinfo->buddy)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1990 SendMessage(cinfo->buddy, WM_USER+10, 0, 0);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1991
109
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
1992 SetTimer(hWnd, 100, 100, (TIMERPROC)NULL);
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
1993
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1994 return ret;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1995 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1996 break;
109
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
1997 case WM_LBUTTONUP:
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
1998 case WM_MBUTTONUP:
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
1999 case WM_RBUTTONUP:
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2000 case WM_KEYUP:
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2001 {
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2002 BOOL ret;
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2003
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2004 if(!cinfo || !cinfo->pOldProc)
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2005 ret = DefWindowProc(hWnd, msg, mp1, mp2);
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2006 ret = CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2);
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2007
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2008 /* Tell the edit control that a buttonpress has
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2009 * occured and to update it's window title.
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2010 */
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2011 if(cinfo && cinfo->buddy)
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2012 SendMessage(cinfo->buddy, WM_USER+10, 0, 0);
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2013
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2014 KillTimer(hWnd, 100);
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2015
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2016 return ret;
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2017 }
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2018 break;
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2019 case WM_TIMER:
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2020 {
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2021 if(mp1 == 100)
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2022 {
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2023 BOOL ret;
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2024
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2025 if(cinfo && cinfo->buddy)
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2026 SendMessage(cinfo->buddy, WM_USER+10, 0, 0);
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2027
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2028 if(!cinfo || !cinfo->pOldProc)
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2029 ret = DefWindowProc(hWnd, msg, mp1, mp2);
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2030 ret = CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2);
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2031
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2032 /* Tell the edit control that a buttonpress has
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2033 * occured and to update it's window title.
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2034 */
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2035 if(cinfo && cinfo->buddy)
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2036 SendMessage(cinfo->buddy, WM_USER+10, 0, 0);
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2037
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2038 return ret;
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2039 }
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2040 }
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2041 break;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2042 case WM_USER+10:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2043 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2044 if(cinfo->buddy)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2045 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2046 char tempbuf[100] = "";
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2047 long position;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2048
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2049 GetWindowText(cinfo->buddy, tempbuf, 99);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2050
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2051 position = atol(tempbuf);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2052
75
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
2053 if(IS_IE5PLUS)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2054 SendMessage(hWnd, UDM_SETPOS32, 0, (LPARAM)position);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2055 else
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2056 SendMessage(hWnd, UDM_SETPOS, 0, (LPARAM)MAKELONG((short)position, 0));
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2057 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2058 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2059 break;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2060 }
57
1ed95c8ec2ff Added a mutex lock and unlock in the pointer calls. And fixed a warning
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 55
diff changeset
2061 }
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2062
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2063 if(!cinfo || !cinfo->pOldProc)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2064 return DefWindowProc(hWnd, msg, mp1, mp2);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2065 return CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2066 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2067
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2068 void _click_default(HWND handle)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2069 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2070 char tmpbuf[100];
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2071
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2072 GetClassName(handle, tmpbuf, 99);
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2073
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2074 /* These are the window classes which can
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2075 * obtain input focus.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2076 */
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2077 if(strnicmp(tmpbuf, BUTTONCLASSNAME, strlen(BUTTONCLASSNAME))==0)
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2078 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2079 /* Generate click on default item */
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2080 SignalHandler *tmp = Root;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2081
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2082 /* Find any callbacks for this function */
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2083 while(tmp)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2084 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2085 if(tmp->message == WM_COMMAND)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2086 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2087 int (*clickfunc)(HWND, void *) = tmp->signalfunction;
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2088
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2089 /* Make sure it's the right window, and the right ID */
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2090 if(tmp->window == handle)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2091 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2092 clickfunc(tmp->window, tmp->data);
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2093 tmp = NULL;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2094 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2095 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2096 if(tmp)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2097 tmp= tmp->next;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2098 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2099 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2100 else
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2101 SetFocus(handle);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2102 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2103
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2104 BOOL CALLBACK _colorwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2105 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2106 ColorInfo *cinfo;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2107 char tmpbuf[100];
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2108 WNDPROC pOldProc = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2109
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2110 cinfo = (ColorInfo *)GetWindowLong(hWnd, GWL_USERDATA);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2111
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2112 GetClassName(hWnd, tmpbuf, 99);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2113 if(strcmp(tmpbuf, FRAMECLASSNAME) == 0)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2114 cinfo = &(((Box *)cinfo)->cinfo);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2115
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2116 if(cinfo)
57
1ed95c8ec2ff Added a mutex lock and unlock in the pointer calls. And fixed a warning
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 55
diff changeset
2117 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2118 pOldProc = cinfo->pOldProc;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2119
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2120 switch( msg )
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2121 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2122 case WM_SETFOCUS:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2123 if(cinfo->combo)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2124 _wndproc(cinfo->combo, msg, mp1, mp2);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2125 else
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2126 _wndproc(hWnd, msg, mp1, mp2);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2127 break;
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
2128 case WM_VSCROLL:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
2129 case WM_HSCROLL:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
2130 _wndproc(hWnd, msg, mp1, mp2);
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
2131 break;
110
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2132 case WM_KEYDOWN:
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2133 case WM_KEYUP:
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2134 {
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2135 if(mp1 == VK_UP || mp1 == VK_DOWN)
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2136 {
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2137 BOOL ret;
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2138
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2139 if(!cinfo || !cinfo->pOldProc)
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2140 ret = DefWindowProc(hWnd, msg, mp1, mp2);
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2141 ret = CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2);
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2142
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2143 /* Tell the spinner control that a keypress has
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2144 * occured and to update it's internal value.
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2145 */
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2146 if(cinfo && cinfo->buddy && !cinfo->combo)
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2147 PostMessage(hWnd, WM_USER+10, 0, 0);
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2148
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2149 if(msg == WM_KEYDOWN)
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2150 SetTimer(hWnd, 101, 100, (TIMERPROC)NULL);
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2151 else
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2152 KillTimer(hWnd, 101);
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2153
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2154 return ret;
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2155 }
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2156 }
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2157 break;
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2158 case WM_TIMER:
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2159 {
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2160 if(mp1 == 101)
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2161 {
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2162 BOOL ret;
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2163
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2164 if(!cinfo || !cinfo->pOldProc)
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2165 ret = DefWindowProc(hWnd, msg, mp1, mp2);
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2166 ret = CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2);
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2167
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2168 /* Tell the spinner control that a keypress has
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2169 * occured and to update it's internal value.
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2170 */
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2171 if(cinfo && cinfo->buddy && !cinfo->combo)
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2172 PostMessage(hWnd, WM_USER+10, 0, 0);
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2173
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2174 return ret;
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2175 }
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2176 }
d4c1a9ebc72f Spinbutton behaviour cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 109
diff changeset
2177 break;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2178 case WM_CHAR:
277
d706e0dbb0cb Pass WM_CHAR messages to the signal handler proc for boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 267
diff changeset
2179 _wndproc(hWnd, msg, mp1, mp2);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2180 if(LOWORD(mp1) == '\t')
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2181 {
82
aec9a0b0b539 Fixes for a resource leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 79
diff changeset
2182 if(GetAsyncKeyState(VK_SHIFT) & 0x8000)
61
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2183 {
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2184 if(cinfo->combo)
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2185 _shift_focus_back(cinfo->combo);
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2186 else if(cinfo->buddy)
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2187 _shift_focus_back(cinfo->buddy);
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2188 else
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2189 _shift_focus_back(hWnd);
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2190 }
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2191 else
61
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2192 {
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2193 if(cinfo->combo)
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2194 _shift_focus(cinfo->combo);
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2195 else if(cinfo->buddy)
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2196 _shift_focus(cinfo->buddy);
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2197 else
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2198 _shift_focus(hWnd);
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2199 }
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2200 return FALSE;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2201 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2202 else if(LOWORD(mp1) == '\r')
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2203 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2204 if(cinfo->clickdefault)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2205 _click_default(cinfo->clickdefault);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2206
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2207 }
111
1e406d67b178 Readded a piece of code I accidentally removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 110
diff changeset
2208
1e406d67b178 Readded a piece of code I accidentally removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 110
diff changeset
2209 /* Tell the spinner control that a keypress has
1e406d67b178 Readded a piece of code I accidentally removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 110
diff changeset
2210 * occured and to update it's internal value.
1e406d67b178 Readded a piece of code I accidentally removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 110
diff changeset
2211 */
1e406d67b178 Readded a piece of code I accidentally removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 110
diff changeset
2212 if(cinfo->buddy && !cinfo->combo)
1e406d67b178 Readded a piece of code I accidentally removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 110
diff changeset
2213 {
1e406d67b178 Readded a piece of code I accidentally removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 110
diff changeset
2214 if(IsWinNT())
1e406d67b178 Readded a piece of code I accidentally removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 110
diff changeset
2215 PostMessage(cinfo->buddy, WM_USER+10, 0, 0);
1e406d67b178 Readded a piece of code I accidentally removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 110
diff changeset
2216 else
1e406d67b178 Readded a piece of code I accidentally removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 110
diff changeset
2217 SendMessage(cinfo->buddy, WM_USER+10, 0, 0);
1e406d67b178 Readded a piece of code I accidentally removed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 110
diff changeset
2218 }
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2219 break;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2220 case WM_USER+10:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2221 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2222 if(cinfo->buddy)
57
1ed95c8ec2ff Added a mutex lock and unlock in the pointer calls. And fixed a warning
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 55
diff changeset
2223 {
79
8082cb0e7c2e Updated to the latest DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 75
diff changeset
2224 long val;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2225
75
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
2226 if(IS_IE5PLUS)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2227 val = (long)SendMessage(cinfo->buddy, UDM_GETPOS32, 0, 0);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2228 else
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2229 val = (long)SendMessage(cinfo->buddy, UDM_GETPOS, 0, 0);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2230
79
8082cb0e7c2e Updated to the latest DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 75
diff changeset
2231 sprintf(tmpbuf, "%d", val);
8082cb0e7c2e Updated to the latest DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 75
diff changeset
2232 SetWindowText(hWnd, tmpbuf);
57
1ed95c8ec2ff Added a mutex lock and unlock in the pointer calls. And fixed a warning
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 55
diff changeset
2233 }
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2234 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2235 break;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2236 case WM_CTLCOLORSTATIC:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2237 case WM_CTLCOLORLISTBOX:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2238 case WM_CTLCOLORBTN:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2239 case WM_CTLCOLOREDIT:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2240 case WM_CTLCOLORMSGBOX:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2241 case WM_CTLCOLORSCROLLBAR:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2242 case WM_CTLCOLORDLG:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2243 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2244 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLong((HWND)mp2, GWL_USERDATA);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2245 if(thiscinfo && thiscinfo->fore != -1 && thiscinfo->back != -1)
57
1ed95c8ec2ff Added a mutex lock and unlock in the pointer calls. And fixed a warning
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 55
diff changeset
2246 {
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2247 /* Handle foreground */
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2248 if(thiscinfo->fore > -1 && thiscinfo->fore < 18)
57
1ed95c8ec2ff Added a mutex lock and unlock in the pointer calls. And fixed a warning
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 55
diff changeset
2249 {
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2250 if(thiscinfo->fore != DW_CLR_DEFAULT)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2251 {
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2252 SetTextColor((HDC)mp1, RGB(_red[thiscinfo->fore],
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2253 _green[thiscinfo->fore],
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2254 _blue[thiscinfo->fore]));
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2255 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2256 }
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2257 else if((thiscinfo->fore & DW_RGB_COLOR) == DW_RGB_COLOR)
57
1ed95c8ec2ff Added a mutex lock and unlock in the pointer calls. And fixed a warning
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 55
diff changeset
2258 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2259 SetTextColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->fore),
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2260 DW_GREEN_VALUE(thiscinfo->fore),
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2261 DW_BLUE_VALUE(thiscinfo->fore)));
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2262 }
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2263 /* Handle background */
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2264 if(thiscinfo->back > -1 && thiscinfo->back < 18)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2265 {
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2266 if(thiscinfo->back == DW_CLR_DEFAULT)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2267 {
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2268 HBRUSH hbr = GetSysColorBrush(COLOR_3DFACE);
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2269
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2270 SetBkColor((HDC)mp1, GetSysColor(COLOR_3DFACE));
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2271
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2272
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2273 SelectObject((HDC)mp1, hbr);
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2274 return (LONG)hbr;
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2275 }
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2276 else
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2277 {
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2278 SetBkColor((HDC)mp1, RGB(_red[thiscinfo->back],
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2279 _green[thiscinfo->back],
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2280 _blue[thiscinfo->back]));
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2281 if(thiscinfo->hbrush)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2282 DeleteObject(thiscinfo->hbrush);
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2283 thiscinfo->hbrush = CreateSolidBrush(RGB(_red[thiscinfo->back],
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2284 _green[thiscinfo->back],
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2285 _blue[thiscinfo->back]));
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2286 SelectObject((HDC)mp1, thiscinfo->hbrush);
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2287 }
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2288 return (LONG)thiscinfo->hbrush;
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2289 }
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2290 else if((thiscinfo->back & DW_RGB_COLOR) == DW_RGB_COLOR)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2291 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2292 SetBkColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->back),
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2293 DW_GREEN_VALUE(thiscinfo->back),
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2294 DW_BLUE_VALUE(thiscinfo->back)));
82
aec9a0b0b539 Fixes for a resource leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 79
diff changeset
2295 if(thiscinfo->hbrush)
aec9a0b0b539 Fixes for a resource leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 79
diff changeset
2296 DeleteObject(thiscinfo->hbrush);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2297 thiscinfo->hbrush = CreateSolidBrush(RGB(DW_RED_VALUE(thiscinfo->back),
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2298 DW_GREEN_VALUE(thiscinfo->back),
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2299 DW_BLUE_VALUE(thiscinfo->back)));
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2300 SelectObject((HDC)mp1, thiscinfo->hbrush);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2301 return (LONG)thiscinfo->hbrush;
57
1ed95c8ec2ff Added a mutex lock and unlock in the pointer calls. And fixed a warning
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 55
diff changeset
2302 }
1ed95c8ec2ff Added a mutex lock and unlock in the pointer calls. And fixed a warning
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 55
diff changeset
2303 }
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2304
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2305 }
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2306 break;
57
1ed95c8ec2ff Added a mutex lock and unlock in the pointer calls. And fixed a warning
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 55
diff changeset
2307 }
1ed95c8ec2ff Added a mutex lock and unlock in the pointer calls. And fixed a warning
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 55
diff changeset
2308 }
1ed95c8ec2ff Added a mutex lock and unlock in the pointer calls. And fixed a warning
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 55
diff changeset
2309
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2310 if(!pOldProc)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2311 return DefWindowProc(hWnd, msg, mp1, mp2);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2312 return CallWindowProc(pOldProc, hWnd, msg, mp1, mp2);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2313 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2314
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2315 BOOL CALLBACK _containerwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2316 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2317 ContainerInfo *cinfo;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2318
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2319 cinfo = (ContainerInfo *)GetWindowLong(hWnd, GWL_USERDATA);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2320
57
1ed95c8ec2ff Added a mutex lock and unlock in the pointer calls. And fixed a warning
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 55
diff changeset
2321 switch( msg )
1ed95c8ec2ff Added a mutex lock and unlock in the pointer calls. And fixed a warning
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 55
diff changeset
2322 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2323 case WM_COMMAND:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2324 case WM_NOTIFY:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2325 _wndproc(hWnd, msg, mp1, mp2);
57
1ed95c8ec2ff Added a mutex lock and unlock in the pointer calls. And fixed a warning
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 55
diff changeset
2326 break;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2327 case WM_LBUTTONDBLCLK:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2328 case WM_CHAR:
57
1ed95c8ec2ff Added a mutex lock and unlock in the pointer calls. And fixed a warning
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 55
diff changeset
2329 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2330 LV_ITEM lvi;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2331 int iItem;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2332
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2333 if(LOWORD(mp1) == '\t')
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2334 {
82
aec9a0b0b539 Fixes for a resource leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 79
diff changeset
2335 if(GetAsyncKeyState(VK_SHIFT) & 0x8000)
61
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2336 _shift_focus_back(hWnd);
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2337 else
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2338 _shift_focus(hWnd);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2339 return FALSE;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2340 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2341
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2342 if(msg == WM_CHAR && (char)mp1 != '\r')
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2343 break;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2344
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2345 iItem = ListView_GetNextItem(hWnd, -1, LVNI_FOCUSED);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2346
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
2347 memset(&lvi, 0, sizeof(LV_ITEM));
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
2348
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2349 if(iItem > -1)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2350 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2351 lvi.iItem = iItem;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2352 lvi.mask = LVIF_PARAM;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2353
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2354 ListView_GetItem(hWnd, &lvi);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2355 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2356
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2357 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2358 SignalHandler *tmp = Root;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2359
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2360 while(tmp)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2361 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2362 if(tmp->message == NM_DBLCLK && tmp->window == hWnd)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2363 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2364 int (*containerselectfunc)(HWND, char *, void *) = tmp->signalfunction;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2365
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2366 /* Seems to be having lParam as 1 which really sucks */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2367 if(lvi.lParam < 100)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2368 lvi.lParam = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2369
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2370 containerselectfunc(tmp->window, (char *)lvi.lParam, tmp->data);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2371 tmp = NULL;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2372 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2373 if(tmp)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2374 tmp = tmp->next;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2375 }
57
1ed95c8ec2ff Added a mutex lock and unlock in the pointer calls. And fixed a warning
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 55
diff changeset
2376 }
1ed95c8ec2ff Added a mutex lock and unlock in the pointer calls. And fixed a warning
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 55
diff changeset
2377 }
1ed95c8ec2ff Added a mutex lock and unlock in the pointer calls. And fixed a warning
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 55
diff changeset
2378 break;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2379 case WM_CONTEXTMENU:
57
1ed95c8ec2ff Added a mutex lock and unlock in the pointer calls. And fixed a warning
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 55
diff changeset
2380 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2381 SignalHandler *tmp = Root;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2382
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2383 while(tmp)
57
1ed95c8ec2ff Added a mutex lock and unlock in the pointer calls. And fixed a warning
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 55
diff changeset
2384 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2385 if(tmp->message == NM_RCLICK && tmp->window == hWnd)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2386 {
312
ff8f23594b15 Make sure itemdata is NULL for container callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 311
diff changeset
2387 int (*containercontextfunc)(HWND, char *, int, int, void *, void *) = tmp->signalfunction;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2388 LONG x,y;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2389 LV_ITEM lvi;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2390 int iItem;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2391 LVHITTESTINFO lhi;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2392
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2393 dw_pointer_query_pos(&x, &y);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2394
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2395 lhi.pt.x = x;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2396 lhi.pt.y = y;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2397
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2398 MapWindowPoints(HWND_DESKTOP, tmp->window, &lhi.pt, 1);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2399
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2400 iItem = ListView_HitTest(tmp->window, &lhi);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2401
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
2402 memset(&lvi, 0, sizeof(LV_ITEM));
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
2403
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2404 if(iItem > -1)
57
1ed95c8ec2ff Added a mutex lock and unlock in the pointer calls. And fixed a warning
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 55
diff changeset
2405 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2406 lvi.iItem = iItem;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2407 lvi.mask = LVIF_PARAM;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2408
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2409 ListView_GetItem(tmp->window, &lvi);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2410 ListView_SetSelectionMark(tmp->window, iItem);
57
1ed95c8ec2ff Added a mutex lock and unlock in the pointer calls. And fixed a warning
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 55
diff changeset
2411 }
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2412
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2413 /* Seems to be having lParam as 1 which really sucks */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2414 if(lvi.lParam < 100)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2415 lvi.lParam = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2416
312
ff8f23594b15 Make sure itemdata is NULL for container callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 311
diff changeset
2417 containercontextfunc(tmp->window, (char *)lvi.lParam, x, y, tmp->data, NULL);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2418 tmp = NULL;
57
1ed95c8ec2ff Added a mutex lock and unlock in the pointer calls. And fixed a warning
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 55
diff changeset
2419 }
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2420 if(tmp)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2421 tmp = tmp->next;
57
1ed95c8ec2ff Added a mutex lock and unlock in the pointer calls. And fixed a warning
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 55
diff changeset
2422 }
1ed95c8ec2ff Added a mutex lock and unlock in the pointer calls. And fixed a warning
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 55
diff changeset
2423 }
1ed95c8ec2ff Added a mutex lock and unlock in the pointer calls. And fixed a warning
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 55
diff changeset
2424 break;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2425 }
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2426
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2427 if(!cinfo || !cinfo->pOldProc)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2428 return DefWindowProc(hWnd, msg, mp1, mp2);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2429 return CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2430 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2431
68
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
2432 BOOL CALLBACK _treewndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2)
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
2433 {
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
2434 ContainerInfo *cinfo;
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
2435
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
2436 cinfo = (ContainerInfo *)GetWindowLong(hWnd, GWL_USERDATA);
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
2437
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
2438 switch( msg )
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
2439 {
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
2440 case WM_CHAR:
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
2441 if(LOWORD(mp1) == '\t')
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
2442 {
82
aec9a0b0b539 Fixes for a resource leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 79
diff changeset
2443 if(GetAsyncKeyState(VK_SHIFT) & 0x8000)
68
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
2444 _shift_focus_back(hWnd);
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
2445 else
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
2446 _shift_focus(hWnd);
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
2447 return FALSE;
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
2448 }
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
2449 break;
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
2450 }
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
2451
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
2452 if(!cinfo || !cinfo->pOldProc)
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
2453 return DefWindowProc(hWnd, msg, mp1, mp2);
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
2454 return CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2);
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
2455 }
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
2456
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2457 void _changebox(Box *thisbox, int percent, int type)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2458 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2459 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2460
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2461 for(z=0;z<thisbox->count;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2462 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2463 if(thisbox->items[z].type == TYPEBOX)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2464 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2465 Box *tmp = (Box*)GetWindowLong(thisbox->items[z].hwnd, GWL_USERDATA);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2466 _changebox(tmp, percent, type);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2467 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2468 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2469 {
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
2470 if(type == DW_HORZ)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2471 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2472 if(thisbox->items[z].hsize == SIZEEXPAND)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2473 thisbox->items[z].width = (int)(((float)thisbox->items[z].origwidth) * (((float)percent)/((float)100.0)));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2474 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2475 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2476 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2477 if(thisbox->items[z].vsize == SIZEEXPAND)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2478 thisbox->items[z].height = (int)(((float)thisbox->items[z].origheight) * (((float)percent)/((float)100.0)));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2479 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2480 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2481 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2482 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2483
126
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2484 void _handle_splitbar_resize(HWND hwnd, float percent, int type, int x, int y)
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2485 {
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
2486 if(type == DW_HORZ)
126
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2487 {
182
b8caec82a4d2 Minor splitbar fixes on OS/2 and Windows. The splitbar width is now 4
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 181
diff changeset
2488 int newx = x;
126
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2489 float ratio = (float)percent/(float)100.0;
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2490 HWND handle1 = (HWND)dw_window_get_data(hwnd, "_dw_topleft");
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2491 HWND handle2 = (HWND)dw_window_get_data(hwnd, "_dw_bottomright");
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2492 Box *tmp = (Box *)GetWindowLong(handle1, GWL_USERDATA);
126
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2493
182
b8caec82a4d2 Minor splitbar fixes on OS/2 and Windows. The splitbar width is now 4
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 181
diff changeset
2494 newx = (int)((float)newx * ratio) - (SPLITBAR_WIDTH/2);
126
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2495
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2496 ShowWindow(handle1, SW_HIDE);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2497 ShowWindow(handle2, SW_HIDE);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2498
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2499 MoveWindow(handle1, 0, 0, newx, y, FALSE);
182
b8caec82a4d2 Minor splitbar fixes on OS/2 and Windows. The splitbar width is now 4
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 181
diff changeset
2500 _do_resize(tmp, newx - 1, y - 1);
126
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2501
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2502 tmp = (Box *)GetWindowLong(handle2, GWL_USERDATA);
126
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2503
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2504 newx = x - newx - SPLITBAR_WIDTH;
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2505
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2506 MoveWindow(handle2, x - newx, 0, newx, y, FALSE);
182
b8caec82a4d2 Minor splitbar fixes on OS/2 and Windows. The splitbar width is now 4
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 181
diff changeset
2507 _do_resize(tmp, newx - 1, y - 1);
126
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2508
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2509 ShowWindow(handle1, SW_SHOW);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2510 ShowWindow(handle2, SW_SHOW);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2511
126
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2512 dw_window_set_data(hwnd, "_dw_start", (void *)newx);
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2513 }
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2514 else
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2515 {
182
b8caec82a4d2 Minor splitbar fixes on OS/2 and Windows. The splitbar width is now 4
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 181
diff changeset
2516 int newy = y;
126
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2517 float ratio = (float)(100.0-percent)/(float)100.0;
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2518 HWND handle1 = (HWND)dw_window_get_data(hwnd, "_dw_bottomright");
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2519 HWND handle2 = (HWND)dw_window_get_data(hwnd, "_dw_topleft");
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2520 Box *tmp = (Box *)GetWindowLong(handle1, GWL_USERDATA);
126
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2521
182
b8caec82a4d2 Minor splitbar fixes on OS/2 and Windows. The splitbar width is now 4
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 181
diff changeset
2522 newy = (int)((float)newy * ratio) - (SPLITBAR_WIDTH/2);
126
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2523
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2524 ShowWindow(handle1, SW_HIDE);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2525 ShowWindow(handle2, SW_HIDE);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2526
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2527 MoveWindow(handle1, 0, y - newy, x, newy, FALSE);
182
b8caec82a4d2 Minor splitbar fixes on OS/2 and Windows. The splitbar width is now 4
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 181
diff changeset
2528 _do_resize(tmp, x - 1, newy - 1);
126
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2529
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2530 tmp = (Box *)GetWindowLong(handle2, GWL_USERDATA);
126
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2531
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2532 newy = y - newy - SPLITBAR_WIDTH;
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2533
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2534 MoveWindow(handle2, 0, 0, x, newy, FALSE);
182
b8caec82a4d2 Minor splitbar fixes on OS/2 and Windows. The splitbar width is now 4
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 181
diff changeset
2535 _do_resize(tmp, x - 1, newy - 1);
126
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2536
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2537 ShowWindow(handle1, SW_SHOW);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2538 ShowWindow(handle2, SW_SHOW);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2539
126
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2540 dw_window_set_data(hwnd, "_dw_start", (void *)newy);
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2541 }
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2542 }
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2543
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2544 /* This handles any activity on the splitbars (sizers) */
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2545 BOOL CALLBACK _splitwndproc(HWND hwnd, UINT msg, WPARAM mp1, LPARAM mp2)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2546 {
124
edf615d8266e Use float instead of int for percent on Windows. And a minor safety check
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2547 float *percent = (float *)dw_window_get_data(hwnd, "_dw_percent");
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
2548 int type = (int)dw_window_get_data(hwnd, "_dw_type");
126
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2549 int start = (int)dw_window_get_data(hwnd, "_dw_start");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2550
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2551 switch (msg)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2552 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2553 case WM_ACTIVATE:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2554 case WM_SETFOCUS:
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2555 return FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2556
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2557 case WM_PAINT:
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
2558 {
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2559 PAINTSTRUCT ps;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2560 HDC hdcPaint;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2561
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2562 BeginPaint(hwnd, &ps);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2563
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2564 if((hdcPaint = GetDC(hwnd)) != NULL)
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2565 {
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2566 int cx, cy;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2567 HBRUSH oldBrush = SelectObject(hdcPaint, GetSysColorBrush(COLOR_3DFACE));
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2568 HPEN oldPen = SelectObject(hdcPaint, CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DFACE)));
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2569
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2570 dw_window_get_pos_size(hwnd, NULL, NULL, &cx, &cy);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2571
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
2572 if(type == DW_HORZ)
182
b8caec82a4d2 Minor splitbar fixes on OS/2 and Windows. The splitbar width is now 4
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 181
diff changeset
2573 Rectangle(hdcPaint, cx - start - SPLITBAR_WIDTH, 0, cx - start, cy);
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2574 else
182
b8caec82a4d2 Minor splitbar fixes on OS/2 and Windows. The splitbar width is now 4
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 181
diff changeset
2575 Rectangle(hdcPaint, 0, start, cx, start + SPLITBAR_WIDTH);
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2576
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2577 SelectObject(hdcPaint, oldBrush);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2578 DeleteObject(SelectObject(hdcPaint, oldPen));
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2579 ReleaseDC(hwnd, hdcPaint);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2580 }
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2581 EndPaint(hwnd, &ps);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2582 }
126
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2583 break;
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2584 case WM_LBUTTONDOWN:
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2585 {
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2586 SetCapture(hwnd);
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2587 break;
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2588 }
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2589 case WM_LBUTTONUP:
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2590 {
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2591 if(GetCapture() == hwnd)
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2592 ReleaseCapture();
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
2593 }
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
2594 break;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2595 case WM_MOUSEMOVE:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2596 {
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
2597 if(type == DW_HORZ)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2598 SetCursor(LoadCursor(NULL, IDC_SIZEWE));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2599 else
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2600 SetCursor(LoadCursor(NULL, IDC_SIZENS));
126
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2601
127
c5c3ccb84ac7 Safety checks in the splitbar calculations on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 126
diff changeset
2602 if(GetCapture() == hwnd && percent)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2603 {
126
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2604 POINT point;
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2605 RECT rect;
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
2606 static POINT lastpoint;
126
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2607
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2608 GetCursorPos(&point);
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2609 GetWindowRect(hwnd, &rect);
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2610
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
2611 if(memcmp(&point, &lastpoint, sizeof(POINT)))
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2612 {
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
2613 if(PtInRect(&rect, point))
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2614 {
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
2615 int width = (rect.right - rect.left);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
2616 int height = (rect.bottom - rect.top);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
2617
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
2618 if(type == DW_HORZ)
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
2619 {
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
2620 start = point.x - rect.left;
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
2621 if(width - SPLITBAR_WIDTH > 1 && start < width - SPLITBAR_WIDTH)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
2622 *percent = ((float)start / (float)(width - SPLITBAR_WIDTH)) * 100.0;
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
2623 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
2624 else
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
2625 {
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
2626 start = point.y - rect.top;
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
2627 if(height - SPLITBAR_WIDTH > 1 && start < height - SPLITBAR_WIDTH)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
2628 *percent = ((float)start / (float)(height - SPLITBAR_WIDTH)) * 100.0;
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
2629 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
2630 _handle_splitbar_resize(hwnd, *percent, type, width, height);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2631 }
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
2632 memcpy(&lastpoint, &point, sizeof(POINT));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2633 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2634 }
126
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
2635 break;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2636 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2637 }
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2638 return DefWindowProc(hwnd, msg, mp1, mp2);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2639 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2640
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2641 /* This handles drawing the status text areas */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2642 BOOL CALLBACK _statuswndproc(HWND hwnd, UINT msg, WPARAM mp1, LPARAM mp2)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2643 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2644 switch (msg)
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2645 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2646 case WM_SETTEXT:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2647 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2648 /* Make sure the control redraws when there is a text change */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2649 int ret = (int)DefWindowProc(hwnd, msg, mp1, mp2);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2650
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2651 InvalidateRgn(hwnd, NULL, TRUE);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2652 return ret;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2653 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2654 case WM_PAINT:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2655 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2656 HDC hdcPaint;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2657 PAINTSTRUCT ps;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2658 RECT rc;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2659 unsigned long cx, cy;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2660 int threadid = dw_thread_id();
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2661 char tempbuf[1024] = "";
299
2a97f8d9b297 Use DrawStatusText() to make the status lines, instead of doing it ourself.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 298
diff changeset
2662 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(hwnd, GWL_USERDATA);
2a97f8d9b297 Use DrawStatusText() to make the status lines, instead of doing it ourself.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 298
diff changeset
2663 HFONT hfont = _acquire_font(hwnd, cinfo ? cinfo->fontname : NULL);
2a97f8d9b297 Use DrawStatusText() to make the status lines, instead of doing it ourself.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 298
diff changeset
2664 HFONT oldfont = (HFONT)SendMessage(hwnd, WM_GETFONT, 0, 0);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2665
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2666 dw_window_get_pos_size(hwnd, NULL, NULL, &cx, &cy);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2667 GetWindowText(hwnd, tempbuf, 1024);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2668
299
2a97f8d9b297 Use DrawStatusText() to make the status lines, instead of doing it ourself.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 298
diff changeset
2669 hdcPaint = BeginPaint(hwnd, &ps);
2a97f8d9b297 Use DrawStatusText() to make the status lines, instead of doing it ourself.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 298
diff changeset
2670 if(hfont)
2a97f8d9b297 Use DrawStatusText() to make the status lines, instead of doing it ourself.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 298
diff changeset
2671 oldfont = (HFONT)SelectObject(hdcPaint, hfont);
2a97f8d9b297 Use DrawStatusText() to make the status lines, instead of doing it ourself.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 298
diff changeset
2672 rc.top = rc.left = 0;
2a97f8d9b297 Use DrawStatusText() to make the status lines, instead of doing it ourself.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 298
diff changeset
2673 rc.right = cx;
2a97f8d9b297 Use DrawStatusText() to make the status lines, instead of doing it ourself.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 298
diff changeset
2674 rc.bottom = cy;
2a97f8d9b297 Use DrawStatusText() to make the status lines, instead of doing it ourself.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 298
diff changeset
2675 DrawStatusText(hdcPaint, &rc, tempbuf, 0);
2a97f8d9b297 Use DrawStatusText() to make the status lines, instead of doing it ourself.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 298
diff changeset
2676 if(hfont && oldfont)
2a97f8d9b297 Use DrawStatusText() to make the status lines, instead of doing it ourself.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 298
diff changeset
2677 SelectObject(hdcPaint, oldfont);
2a97f8d9b297 Use DrawStatusText() to make the status lines, instead of doing it ourself.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 298
diff changeset
2678 if(hfont)
2a97f8d9b297 Use DrawStatusText() to make the status lines, instead of doing it ourself.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 298
diff changeset
2679 DeleteObject(hfont);
2a97f8d9b297 Use DrawStatusText() to make the status lines, instead of doing it ourself.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 298
diff changeset
2680 EndPaint(hwnd, &ps);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2681 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2682 return FALSE;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2683 }
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2684 return DefWindowProc(hwnd, msg, mp1, mp2);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2685 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2686
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2687 /* Function: _BtProc
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2688 * Abstract: Subclass procedure for buttons
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2689 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2690
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2691 BOOL CALLBACK _BtProc(HWND hwnd, ULONG msg, WPARAM mp1, LPARAM mp2)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2692 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2693 BubbleButton *bubble;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2694 static int bMouseOver = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2695 POINT point;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2696 RECT rect;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2697 WNDPROC pOldProc;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2698
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2699 bubble = (BubbleButton *)GetWindowLong(hwnd, GWL_USERDATA);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2700
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2701 if(!bubble)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2702 return DefWindowProc(hwnd, msg, mp1, mp2);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2703
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2704 /* We must save a pointer to the old
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2705 * window procedure because if a signal
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2706 * handler attached here destroys this
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2707 * window it will then be invalid.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2708 */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2709 pOldProc = bubble->pOldProc;
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2710
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2711 switch(msg)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2712 {
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2713 case WM_SETFOCUS:
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2714 _wndproc(hwnd, msg, mp1, mp2);
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2715 break;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2716 case WM_LBUTTONUP:
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2717 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2718 SignalHandler *tmp = Root;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2719
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2720 /* Find any callbacks for this function */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2721 while(tmp)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2722 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2723 if(tmp->message == WM_COMMAND)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2724 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2725 int (*clickfunc)(HWND, void *) = tmp->signalfunction;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2726
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2727 /* Make sure it's the right window, and the right ID */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2728 if(tmp->window == hwnd)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2729 {
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
2730 if(bubble->checkbox)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
2731 in_checkbox_handler = 1;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
2732
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2733 clickfunc(tmp->window, tmp->data);
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
2734
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
2735 if(bubble->checkbox)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
2736 in_checkbox_handler = 0;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2737 tmp = NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2738 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2739 }
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2740 if(tmp)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2741 tmp= tmp->next;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2742 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2743 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2744 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2745 case WM_CHAR:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2746 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2747 /* A button press should also occur for an ENTER or SPACE press
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2748 * while the button has the active input focus.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2749 */
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2750 if(LOWORD(mp1) == '\r' || LOWORD(mp1) == ' ')
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2751 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2752 SignalHandler *tmp = Root;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2753
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2754 /* Find any callbacks for this function */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2755 while(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2756 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2757 if(tmp->message == WM_COMMAND)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2758 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2759 int (*clickfunc)(HWND, void *) = tmp->signalfunction;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2760
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2761 /* Make sure it's the right window, and the right ID */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2762 if(tmp->window == hwnd)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2763 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2764 clickfunc(tmp->window, tmp->data);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2765 tmp = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2766 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2767 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2768 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2769 tmp= tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2770 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2771 }
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2772 if(LOWORD(mp1) == '\t')
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2773 {
82
aec9a0b0b539 Fixes for a resource leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 79
diff changeset
2774 if(GetAsyncKeyState(VK_SHIFT) & 0x8000)
61
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2775 _shift_focus_back(hwnd);
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2776 else
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2777 _shift_focus(hwnd);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2778 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2779 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2780 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2781 break;
61
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2782 case WM_KEYDOWN:
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2783 if(mp1 == VK_LEFT || mp1 == VK_UP)
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2784 _shift_focus_back(hwnd);
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2785 if(mp1 == VK_RIGHT || mp1 == VK_DOWN)
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2786 _shift_focus(hwnd);
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2787 break;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2788 case WM_TIMER:
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2789 if (hwndBubble)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2790 {
82
aec9a0b0b539 Fixes for a resource leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 79
diff changeset
2791 _free_window_memory(hwndBubble, 0);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2792 DestroyWindow(hwndBubble);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2793 hwndBubble = 0;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2794 KillTimer(hwnd, 1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2795 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2796 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2797
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2798 case WM_MOUSEMOVE:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2799 GetCursorPos(&point);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2800 GetWindowRect(hwnd, &rect);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2801
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2802 if(PtInRect(&rect, point))
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
2803 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2804 if(hwnd != GetCapture())
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2805 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2806 SetCapture(hwnd);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2807 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2808 if(!bMouseOver)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2809 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2810 bMouseOver = 1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2811 if(!*bubble->bubbletext)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2812 break;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2813
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2814 if(hwndBubble)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2815 {
82
aec9a0b0b539 Fixes for a resource leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 79
diff changeset
2816 _free_window_memory(hwndBubble, 0);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2817 DestroyWindow(hwndBubble);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2818 hwndBubble = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2819 KillTimer(hwndBubbleLast, 1);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2820 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2821
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2822 if(!hwndBubble)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2823 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2824 POINTL ptlWork = {0,0};
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2825 ULONG ulColor = DW_CLR_YELLOW;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2826 SIZE size;
82
aec9a0b0b539 Fixes for a resource leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 79
diff changeset
2827 HFONT hFont, oldFont = (HFONT)0;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2828 HDC hdc;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2829 RECT rect;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2830 void *oldproc;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2831
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2832 /* Use the WS_EX_TOOLWINDOW extended style
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2833 * so the window doesn't get listed in the
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2834 * taskbar.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2835 */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2836 hwndBubble = CreateWindowEx(WS_EX_TOOLWINDOW,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2837 STATICCLASSNAME,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2838 bubble->bubbletext,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2839 BS_TEXT | WS_POPUP |
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2840 WS_BORDER |
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2841 SS_CENTER,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2842 0,0,50,20,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2843 HWND_DESKTOP,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2844 NULL,
109
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
2845 DWInstance,
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2846 NULL);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2847
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2848 dw_window_set_font(hwndBubble, DefaultFont);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2849 dw_window_set_color(hwndBubble, DW_CLR_BLACK, DW_CLR_YELLOW);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2850
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2851 hwndBubbleLast = hwnd;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2852
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2853 SetTimer(hwnd, 1, 3000, NULL);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2854
82
aec9a0b0b539 Fixes for a resource leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 79
diff changeset
2855 hFont = (HFONT)SendMessage(hwndBubble, WM_GETFONT, 0, 0);
aec9a0b0b539 Fixes for a resource leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 79
diff changeset
2856
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2857 hdc = GetDC(hwndBubble);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2858
82
aec9a0b0b539 Fixes for a resource leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 79
diff changeset
2859 if(hFont)
aec9a0b0b539 Fixes for a resource leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 79
diff changeset
2860 oldFont = (HFONT)SelectObject(hdc, hFont);
aec9a0b0b539 Fixes for a resource leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 79
diff changeset
2861
aec9a0b0b539 Fixes for a resource leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 79
diff changeset
2862 GetTextExtentPoint32(hdc, bubble->bubbletext, strlen(bubble->bubbletext), &size);
aec9a0b0b539 Fixes for a resource leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 79
diff changeset
2863
aec9a0b0b539 Fixes for a resource leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 79
diff changeset
2864 if(hFont)
aec9a0b0b539 Fixes for a resource leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 79
diff changeset
2865 SelectObject(hdc, oldFont);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2866
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2867 MapWindowPoints(hwnd, HWND_DESKTOP, (LPPOINT)&ptlWork, 1);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2868
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2869 GetWindowRect(hwnd, &rect);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2870
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2871 SetWindowPos(hwndBubble,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2872 HWND_TOP,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2873 ptlWork.x,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2874 ptlWork.y + (rect.bottom-rect.top) + 1,
82
aec9a0b0b539 Fixes for a resource leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 79
diff changeset
2875 size.cx + 8,
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2876 size.cy + 2,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2877 SWP_NOACTIVATE | SWP_SHOWWINDOW);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2878
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2879 ReleaseDC(hwndBubble, hdc);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2880 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2881 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2882 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2883 else{
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2884 /* Calling ReleaseCapture in Win95 also causes WM_CAPTURECHANGED
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2885 * to be sent. Be sure to account for that.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2886 */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2887 ReleaseCapture();
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2888
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2889 if(bMouseOver)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2890 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2891 bMouseOver = 0;
82
aec9a0b0b539 Fixes for a resource leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 79
diff changeset
2892 _free_window_memory(hwndBubble, 0);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2893 DestroyWindow(hwndBubble);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2894 hwndBubble = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2895 KillTimer(hwndBubbleLast, 1);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2896 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2897 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2898 break;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2899 case WM_CAPTURECHANGED:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2900 /* This message means we are losing the capture for some reason
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2901 * Either because we intentionally lost it or another window
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2902 * stole it
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2903 */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2904 if(bMouseOver)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2905 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2906 bMouseOver = 0;
82
aec9a0b0b539 Fixes for a resource leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 79
diff changeset
2907 _free_window_memory(hwndBubble, 0);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2908 DestroyWindow(hwndBubble);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2909 hwndBubble = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2910 KillTimer(hwndBubbleLast, 1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2911 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2912 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2913 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2914
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2915 if(!pOldProc)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2916 return DefWindowProc(hwnd, msg, mp1, mp2);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2917 return CallWindowProc(pOldProc, hwnd, msg, mp1, mp2);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2918 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2919
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2920 /* This function recalculates a notebook page for example
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2921 * during switching of notebook pages.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2922 */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2923 void _resize_notebook_page(HWND handle, int pageid)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2924 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2925 RECT rect;
191
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
2926 NotebookPage **array = (NotebookPage **)dw_window_get_data(handle, "_dw_array");
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2927
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2928 if(array && array[pageid])
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2929 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2930 Box *box = (Box *)GetWindowLong(array[pageid]->hwnd, GWL_USERDATA);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2931
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2932 GetClientRect(handle,&rect);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2933 TabCtrl_AdjustRect(handle,FALSE,&rect);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2934 MoveWindow(array[pageid]->hwnd, rect.left, rect.top,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2935 rect.right - rect.left, rect.bottom-rect.top, TRUE);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2936 if(box && box->count)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2937 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2938 ShowWindow(box->items[0].hwnd, SW_HIDE);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2939 _do_resize(box, rect.right - rect.left, rect.bottom - rect.top);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2940 ShowWindow(box->items[0].hwnd, SW_SHOW);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2941 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2942
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2943 ShowWindow(array[pageid]->hwnd, SW_SHOWNORMAL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2944 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2945 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2946
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2947 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2948 * Initializes the Dynamic Windows engine.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2949 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2950 * newthread: True if this is the only thread.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2951 * False if there is already a message loop running.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2952 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
2953 int API dw_init(int newthread, int argc, char *argv[])
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2954 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2955 WNDCLASS wc;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2956 int z;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2957 INITCOMMONCONTROLSEX icc;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2958
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2959 icc.dwSize = sizeof(INITCOMMONCONTROLSEX);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2960 icc.dwICC = ICC_WIN95_CLASSES;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2961
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2962 InitCommonControlsEx(&icc);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2963
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2964 memset(lookup, 0, sizeof(HICON) * ICON_INDEX_LIMIT);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2965
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2966 /* Register the generic Dynamic Windows class */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2967 memset(&wc, 0, sizeof(WNDCLASS));
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2968 wc.style = CS_DBLCLKS;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2969 wc.lpfnWndProc = (WNDPROC)_wndproc;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2970 wc.cbClsExtra = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2971 wc.cbWndExtra = 32;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2972 wc.hbrBackground = NULL;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2973 wc.lpszMenuName = NULL;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2974 wc.lpszClassName = ClassName;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2975
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2976 RegisterClass(&wc);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2977
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2978 /* Register the splitbar control */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2979 memset(&wc, 0, sizeof(WNDCLASS));
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2980 wc.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2981 wc.lpfnWndProc = (WNDPROC)_splitwndproc;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2982 wc.cbClsExtra = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2983 wc.cbWndExtra = 0;
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
2984 wc.hbrBackground = NULL;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2985 wc.lpszMenuName = NULL;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2986 wc.lpszClassName = SplitbarClassName;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2987
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2988 RegisterClass(&wc);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2989
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2990 /* Register a frame control like on OS/2 */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2991 memset(&wc, 0, sizeof(WNDCLASS));
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2992 wc.style = CS_DBLCLKS;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2993 wc.lpfnWndProc = (WNDPROC)_framewndproc;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2994 wc.cbClsExtra = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2995 wc.cbWndExtra = 32;
73
2f339dd13496 Added C/C++ style escape sequence processing. And fixed a couple OS/2 and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 72
diff changeset
2996 wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_3DFACE);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2997 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2998 wc.lpszMenuName = NULL;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2999 wc.lpszClassName = FRAMECLASSNAME;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3000
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3001 RegisterClass(&wc);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3002
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3003 /* Create a set of brushes using the default OS/2 and DOS colors */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3004 for(z=0;z<18;z++)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3005 _colors[z] = CreateSolidBrush(RGB(_red[z],_green[z],_blue[z]));
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3006
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3007 /* Register an Object Windows class like OS/2 and Win2k+
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3008 * so similar functionality can be used on earlier releases
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3009 * of Windows.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3010 */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3011 memset(&wc, 0, sizeof(WNDCLASS));
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3012 wc.style = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3013 wc.lpfnWndProc = (WNDPROC)_wndproc;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3014 wc.cbClsExtra = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3015 wc.cbWndExtra = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3016 wc.hbrBackground = NULL;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3017 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3018 wc.lpszMenuName = NULL;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3019 wc.lpszClassName = ObjectClassName;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3020
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3021 RegisterClass(&wc);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3022
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3023 /* Since Windows 95/98/NT don't have a HWND_OBJECT class
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3024 * also known as a input only window, I will create a
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3025 * temporary window that isn't visible and really does nothing
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3026 * except temporarily hold the child windows before they are
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3027 * packed into their correct parent.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3028 */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3029
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3030 DW_HWND_OBJECT = CreateWindow(ObjectClassName, "", 0, 0, 0,
109
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
3031 0, 0, HWND_DESKTOP, NULL, DWInstance, NULL);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3032
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3033 if(!DW_HWND_OBJECT)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3034 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3035 dw_messagebox("Dynamic Windows", "Could not initialize the object window. error code %d", GetLastError());
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3036 exit(1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3037 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3038
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3039 /* We need the version to check capability like up-down controls */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3040 dwVersion = GetVersion();
75
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
3041 dwComctlVer = GetDllVersion(TEXT("comctl32.dll"));
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3042
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3043 for(z=0;z<THREAD_LIMIT;z++)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3044 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3045 _foreground[z] = RGB(128,128,128);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3046 _background[z] = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3047 _hPen[z] = CreatePen(PS_SOLID, 1, _foreground[z]);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3048 _hBrush[z] = CreateSolidBrush(_foreground[z]);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3049 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3050
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3051 return 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3052 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3053
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3054 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3055 * Runs a message loop for Dynamic Windows.
150
2a0d7b57a6da Removed unnecessary parameters from dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
3056 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3057 void API dw_main(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3058 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3059 MSG msg;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3060
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
3061 _dwtid = dw_thread_id();
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
3062
204
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
3063 while(GetMessage(&msg, NULL, 0, 0))
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3064 {
200
446dd8cea477 Removed window parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 197
diff changeset
3065 if(msg.hwnd == NULL && msg.message == WM_TIMER)
446dd8cea477 Removed window parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 197
diff changeset
3066 _wndproc(msg.hwnd, msg.message, msg.wParam, msg.lParam);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3067 TranslateMessage(&msg);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3068 DispatchMessage(&msg);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3069 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3070 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3071
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3072 /*
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
3073 * Runs a message loop for Dynamic Windows, for a period of milliseconds.
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
3074 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
3075 * milliseconds: Number of milliseconds to run the loop for.
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
3076 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3077 void API dw_main_sleep(int milliseconds)
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
3078 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3079 MSG msg;
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
3080 double start = (double)clock();
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
3081
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
3082 while(((clock() - start) / (CLOCKS_PER_SEC/1000)) <= milliseconds)
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
3083 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3084 if(PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
3085 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3086 GetMessage(&msg, NULL, 0, 0);
200
446dd8cea477 Removed window parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 197
diff changeset
3087 if(msg.hwnd == NULL && msg.message == WM_TIMER)
446dd8cea477 Removed window parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 197
diff changeset
3088 _wndproc(msg.hwnd, msg.message, msg.wParam, msg.lParam);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3089 TranslateMessage(&msg);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3090 DispatchMessage(&msg);
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
3091 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
3092 else
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3093 Sleep(1);
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
3094 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
3095 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
3096
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
3097 /*
204
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
3098 * Processes a single message iteration and returns.
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
3099 */
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
3100 void API dw_main_iteration(void)
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
3101 {
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
3102 MSG msg;
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
3103
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
3104 _dwtid = dw_thread_id();
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
3105
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
3106 if(GetMessage(&msg, NULL, 0, 0))
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
3107 {
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
3108 if(msg.hwnd == NULL && msg.message == WM_TIMER)
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
3109 _wndproc(msg.hwnd, msg.message, msg.wParam, msg.lParam);
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
3110 TranslateMessage(&msg);
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
3111 DispatchMessage(&msg);
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
3112 }
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
3113 }
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
3114
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
3115 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3116 * Free's memory allocated by dynamic windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3117 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3118 * ptr: Pointer to dynamic windows allocated
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3119 * memory to be free()'d.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3120 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3121 void API dw_free(void *ptr)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3122 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3123 free(ptr);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3124 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3125
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3126 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3127 * Allocates and initializes a dialog struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3128 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3129 * data: User defined data to be passed to functions.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3130 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3131 DWDialog * API dw_dialog_new(void *data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3132 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3133 DWDialog *tmp = malloc(sizeof(DWDialog));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3134
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3135 tmp->eve = dw_event_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3136 dw_event_reset(tmp->eve);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3137 tmp->data = data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3138 tmp->done = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3139 tmp->result = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3140
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3141 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3142 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3143
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3144 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3145 * Accepts a dialog struct and returns the given data to the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3146 * initial called of dw_dialog_wait().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3147 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3148 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3149 * result: Data to be returned by dw_dialog_wait().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3150 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3151 int API dw_dialog_dismiss(DWDialog *dialog, void *result)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3152 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3153 dialog->result = result;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3154 dw_event_post(dialog->eve);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3155 dialog->done = TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3156 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3157 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3158
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3159 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3160 * Accepts a dialog struct waits for dw_dialog_dismiss() to be
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3161 * called by a signal handler with the given dialog struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3162 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3163 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3164 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3165 void * API dw_dialog_wait(DWDialog *dialog)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3166 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3167 MSG msg;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3168 void *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3169
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3170 while (GetMessage(&msg,NULL,0,0))
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3171 {
200
446dd8cea477 Removed window parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 197
diff changeset
3172 if(msg.hwnd == NULL && msg.message == WM_TIMER)
446dd8cea477 Removed window parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 197
diff changeset
3173 _wndproc(msg.hwnd, msg.message, msg.wParam, msg.lParam);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3174 TranslateMessage(&msg);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3175 DispatchMessage(&msg);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3176 if(dialog->done)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3177 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3178 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3179 dw_event_close(&dialog->eve);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3180 tmp = dialog->result;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3181 free(dialog);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3182 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3183 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3184
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3185 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3186 * Displays a Message Box with given text and title..
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3187 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3188 * title: The title of the message box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3189 * format: printf style format string.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3190 * ...: Additional variables for use in the format.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3191 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3192 int API dw_messagebox(char *title, char *format, ...)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3193 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3194 va_list args;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3195 char outbuf[256];
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3196
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3197 va_start(args, format);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3198 vsprintf(outbuf, format, args);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3199 va_end(args);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3200
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3201 MessageBox(HWND_DESKTOP, outbuf, title, MB_OK);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3202
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3203 return strlen(outbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3204 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3205
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3206 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3207 * Displays a Message Box with given text and title..
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3208 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3209 * title: The title of the message box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3210 * text: The text to display in the box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3211 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3212 * True if YES False of NO.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3213 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3214 int API dw_yesno(char *title, char *text)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3215 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3216 if(MessageBox(HWND_DESKTOP, text, title, MB_YESNO) == IDYES)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3217 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3218 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3219 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3220
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3221 /*
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3222 * Minimizes or Iconifies a top-level window.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3223 * Parameters:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3224 * handle: The window handle to minimize.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3225 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3226 int API dw_window_minimize(HWND handle)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3227 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3228 return ShowWindow(handle, SW_MINIMIZE);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3229 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3230
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3231 /*
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3232 * Makes the window topmost.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3233 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3234 * handle: The window handle to make topmost.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3235 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3236 int API dw_window_raise(HWND handle)
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3237 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3238 return SetWindowPos(handle, HWND_TOP, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3239 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3240
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3241 /*
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3242 * Makes the window bottommost.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3243 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3244 * handle: The window handle to make bottommost.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3245 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3246 int API dw_window_lower(HWND handle)
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3247 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3248 return SetWindowPos(handle, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3249 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3250
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3251 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3252 * Makes the window visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3253 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3254 * handle: The window handle to make visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3255 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3256 int API dw_window_show(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3257 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3258 int rc = ShowWindow(handle, SW_SHOW);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3259 SetFocus(handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3260 _initial_focus(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3261 return rc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3262 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3263
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3264 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3265 * Makes the window invisible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3266 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3267 * handle: The window handle to make visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3268 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3269 int API dw_window_hide(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3270 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3271 return ShowWindow(handle, SW_HIDE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3272 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3273
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3274 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3275 * Destroys a window and all of it's children.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3276 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3277 * handle: The window handle to destroy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3278 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3279 int API dw_window_destroy(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3280 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3281 HWND parent = GetParent(handle);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3282 Box *thisbox = (Box *)GetWindowLong(parent, GWL_USERDATA);
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3283
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3284 if(parent != HWND_DESKTOP && thisbox && thisbox->count)
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3285 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3286 int z, index = -1;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3287 Item *tmpitem, *thisitem = thisbox->items;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3288
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3289 for(z=0;z<thisbox->count;z++)
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3290 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3291 if(thisitem[z].hwnd == handle)
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3292 index = z;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3293 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3294
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3295 if(index == -1)
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3296 return 0;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3297
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3298 tmpitem = malloc(sizeof(Item)*(thisbox->count-1));
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3299
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3300 /* Copy all but the current entry to the new list */
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3301 for(z=0;z<index;z++)
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3302 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3303 tmpitem[z] = thisitem[z];
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3304 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3305 for(z=index+1;z<thisbox->count;z++)
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3306 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3307 tmpitem[z-1] = thisitem[z];
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3308 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3309
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3310 thisbox->items = tmpitem;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3311 free(thisitem);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3312 thisbox->count--;
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
3313 _free_window_memory(handle, 0);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
3314 EnumChildWindows(handle, _free_window_memory, 0);
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3315 }
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3316 return DestroyWindow(handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3317 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3318
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3319 /* Causes entire window to be invalidated and redrawn.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3320 * Parameters:
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3321 * handle: Toplevel window handle to be redrawn.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3322 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3323 void API dw_window_redraw(HWND handle)
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3324 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3325 Box *mybox = (Box *)GetWindowLong(handle, GWL_USERDATA);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3326
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3327 if(mybox)
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3328 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3329 RECT rect;
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
3330 int istoplevel = (GetParent(handle) == HWND_DESKTOP);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3331
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3332 GetClientRect(handle, &rect);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3333
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
3334 ShowWindow(istoplevel ? mybox->items[0].hwnd : handle, SW_HIDE);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3335 _do_resize(mybox, rect.right - rect.left, rect.bottom - rect.top);
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
3336 ShowWindow(istoplevel ? mybox->items[0].hwnd : handle, SW_SHOW);
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3337 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3338 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3339
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3340 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3341 * Changes a window's parent to newparent.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3342 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3343 * handle: The window handle to destroy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3344 * newparent: The window's new parent window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3345 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3346 void API dw_window_reparent(HWND handle, HWND newparent)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3347 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3348 SetParent(handle, newparent);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3349 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3350
67
ab9b0fa6c66e Focus fixes and removal of several hack in the OS/2 code base.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 63
diff changeset
3351 HFONT _acquire_font(HWND handle, char *fontname)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3352 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3353 HFONT hfont;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3354 int z, size = 9;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3355 LOGFONT lf;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3356
88
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
3357 if(fontname == DefaultFont || !fontname[0])
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3358 hfont = GetStockObject(DEFAULT_GUI_FONT);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3359 else
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3360 {
67
ab9b0fa6c66e Focus fixes and removal of several hack in the OS/2 code base.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 63
diff changeset
3361 #if 0
ab9b0fa6c66e Focus fixes and removal of several hack in the OS/2 code base.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 63
diff changeset
3362 HDC hDC = GetDC(handle);
ab9b0fa6c66e Focus fixes and removal of several hack in the OS/2 code base.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 63
diff changeset
3363 #endif
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3364 for(z=0;z<strlen(fontname);z++)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3365 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3366 if(fontname[z]=='.')
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3367 break;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3368 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3369 size = atoi(fontname) + 5;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3370
67
ab9b0fa6c66e Focus fixes and removal of several hack in the OS/2 code base.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 63
diff changeset
3371 #if 0
ab9b0fa6c66e Focus fixes and removal of several hack in the OS/2 code base.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 63
diff changeset
3372 lf.lfHeight = -MulDiv(size, GetDeviceCaps(hDC, LOGPIXELSY), 72);
ab9b0fa6c66e Focus fixes and removal of several hack in the OS/2 code base.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 63
diff changeset
3373 #endif
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3374 lf.lfHeight = size;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3375 lf.lfWidth = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3376 lf.lfEscapement = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3377 lf.lfOrientation = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3378 lf.lfItalic = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3379 lf.lfUnderline = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3380 lf.lfStrikeOut = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3381 lf.lfWeight = FW_NORMAL;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3382 lf.lfCharSet = DEFAULT_CHARSET;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3383 lf.lfOutPrecision = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3384 lf.lfClipPrecision = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3385 lf.lfQuality = DEFAULT_QUALITY;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3386 lf.lfPitchAndFamily = DEFAULT_PITCH | FW_DONTCARE;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3387 strcpy(lf.lfFaceName, &fontname[z+1]);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3388
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3389 hfont = CreateFontIndirect(&lf);
67
ab9b0fa6c66e Focus fixes and removal of several hack in the OS/2 code base.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 63
diff changeset
3390 #if 0
ab9b0fa6c66e Focus fixes and removal of several hack in the OS/2 code base.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 63
diff changeset
3391 ReleaseDC(handle, hDC);
ab9b0fa6c66e Focus fixes and removal of several hack in the OS/2 code base.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 63
diff changeset
3392 #endif
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3393 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3394 return hfont;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3395 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3396
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3397 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3398 * Sets the font used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3399 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3400 * handle: The window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3401 * fontname: Name and size of the font in the form "size.fontname"
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3402 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3403 int API dw_window_set_font(HWND handle, char *fontname)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3404 {
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
3405 HFONT oldfont = (HFONT)SendMessage(handle, WM_GETFONT, 0, 0);
67
ab9b0fa6c66e Focus fixes and removal of several hack in the OS/2 code base.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 63
diff changeset
3406 HFONT hfont = _acquire_font(handle, fontname);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3407 ColorInfo *cinfo;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3408
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3409 cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3410
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3411 if(fontname)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3412 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3413 if(cinfo)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3414 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3415 strcpy(cinfo->fontname, fontname);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3416 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3417 else
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3418 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3419 cinfo = calloc(1, sizeof(ColorInfo));
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3420 cinfo->fore = cinfo->back = -1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3421
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3422 strcpy(cinfo->fontname, fontname);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3423
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3424 cinfo->pOldProc = SubclassWindow(handle, _colorwndproc);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3425 SetWindowLong(handle, GWL_USERDATA, (ULONG)cinfo);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3426 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3427 }
67
ab9b0fa6c66e Focus fixes and removal of several hack in the OS/2 code base.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 63
diff changeset
3428 SendMessage(handle, WM_SETFONT, (WPARAM)hfont, (LPARAM)TRUE);
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
3429 if(oldfont)
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
3430 DeleteObject(oldfont);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3431 return 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3432 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3433
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3434 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3435 * Sets the colors used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3436 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3437 * handle: The window (widget) handle.
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3438 * fore: Foreground color in RGB format.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3439 * back: Background color in RGB format.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3440 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3441 int API dw_window_set_color(HWND handle, ULONG fore, ULONG back)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3442 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3443 ColorInfo *cinfo;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3444 char tmpbuf[100];
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3445
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3446 cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3447
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3448 GetClassName(handle, tmpbuf, 99);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3449
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3450 if(strnicmp(tmpbuf, WC_LISTVIEW, strlen(WC_LISTVIEW))==0)
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3451 {
191
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
3452 fore = _internal_color(fore);
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
3453 back = _internal_color(back);
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
3454
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3455 ListView_SetTextColor(handle, RGB(DW_RED_VALUE(fore),
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3456 DW_GREEN_VALUE(fore),
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3457 DW_BLUE_VALUE(fore)));
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3458 ListView_SetTextBkColor(handle, RGB(DW_RED_VALUE(back),
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3459 DW_GREEN_VALUE(back),
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3460 DW_BLUE_VALUE(back)));
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3461 ListView_SetBkColor(handle, RGB(DW_RED_VALUE(back),
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3462 DW_GREEN_VALUE(back),
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3463 DW_BLUE_VALUE(back)));
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3464 InvalidateRgn(handle, NULL, TRUE);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3465 return TRUE;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3466 }
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3467
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3468 if(cinfo)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3469 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3470 cinfo->fore = fore;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3471 cinfo->back = back;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3472 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3473 else
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3474 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3475 cinfo = calloc(1, sizeof(ColorInfo));
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3476
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3477 cinfo->fore = fore;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3478 cinfo->back = back;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3479
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3480 cinfo->pOldProc = SubclassWindow(handle, _colorwndproc);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3481 SetWindowLong(handle, GWL_USERDATA, (ULONG)cinfo);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3482 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3483 InvalidateRgn(handle, NULL, TRUE);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3484 return TRUE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3485 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3486
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3487 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3488 * Sets the font used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3489 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3490 * handle: The window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3491 * border: Size of the window border in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3492 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3493 int API dw_window_set_border(HWND handle, int border)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3494 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3495 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3496 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3497
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3498 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3499 * Captures the mouse input to this window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3500 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3501 * handle: Handle to receive mouse input.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3502 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3503 void API dw_window_capture(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3504 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3505 SetCapture(handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3506 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3507
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3508 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3509 * Releases previous mouse capture.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3510 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3511 void API dw_window_release(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3512 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3513 ReleaseCapture();
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3514 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3515
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3516 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3517 * Changes the appearance of the mouse pointer.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3518 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3519 * handle: Handle to widget for which to change.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3520 * cursortype: ID of the pointer you want.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3521 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3522 void API dw_window_pointer(HWND handle, int pointertype)
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3523 {
337
e9a424e641ff Some pointer changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 336
diff changeset
3524 SetCursor(pointer < 65536 ? LoadCursor(NULL, MAKEINTRESOURCE(pointertype)) (HCURSOR)pointertype);
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3525 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3526
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3527 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3528 * Create a new Window Frame.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3529 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3530 * owner: The Owner's window handle or HWND_DESKTOP.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3531 * title: The Window title.
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3532 * flStyle: Style flags, see the DW reference.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3533 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3534 HWND API dw_window_new(HWND hwndOwner, char *title, ULONG flStyle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3535 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3536 HWND hwndframe;
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
3537 Box *newbox = calloc(sizeof(Box), 1);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3538 ULONG flStyleEx = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3539
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3540 newbox->pad = 0;
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
3541 newbox->type = DW_VERT;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3542 newbox->count = 0;
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
3543 newbox->cinfo.fore = newbox->cinfo.back = -1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3544
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3545 if(hwndOwner)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3546 flStyleEx |= WS_EX_MDICHILD;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3547
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3548 if(!(flStyle & WS_CAPTION))
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3549 flStyle |= WS_POPUPWINDOW;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3550
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3551 if(flStyle & DW_FCF_TASKLIST)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3552 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3553 ULONG newflags = (flStyle | WS_CLIPCHILDREN) & ~DW_FCF_TASKLIST;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3554
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3555 hwndframe = CreateWindowEx(flStyleEx, ClassName, title, newflags, CW_USEDEFAULT, CW_USEDEFAULT,
109
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
3556 CW_USEDEFAULT, CW_USEDEFAULT, hwndOwner, NULL, DWInstance, NULL);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3557 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3558 else
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3559 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3560 flStyleEx |= WS_EX_TOOLWINDOW;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3561
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3562 hwndframe = CreateWindowEx(flStyleEx, ClassName, title, flStyle | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT,
109
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
3563 CW_USEDEFAULT, CW_USEDEFAULT, hwndOwner, NULL, DWInstance, NULL);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3564 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3565 SetWindowLong(hwndframe, GWL_USERDATA, (ULONG)newbox);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3566
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3567 #if 0
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3568 if(hwndOwner)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3569 SetParent(hwndframe, hwndOwner);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3570 #endif
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
3571
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3572 return hwndframe;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3573 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3574
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3575 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3576 * Create a new Box to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3577 * Parameters:
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
3578 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3579 * pad: Number of pixels to pad around the box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3580 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3581 HWND API dw_box_new(int type, int pad)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3582 {
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
3583 Box *newbox = calloc(sizeof(Box), 1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3584 HWND hwndframe;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3585
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3586 newbox->pad = pad;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3587 newbox->type = type;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3588 newbox->count = 0;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3589 newbox->grouphwnd = (HWND)NULL;
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
3590 newbox->cinfo.fore = newbox->cinfo.back = -1;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3591
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3592 hwndframe = CreateWindow(FRAMECLASSNAME,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3593 "",
107
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 106
diff changeset
3594 WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN,
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3595 0,0,2000,1000,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3596 DW_HWND_OBJECT,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3597 NULL,
109
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
3598 DWInstance,
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3599 NULL);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3600
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3601 newbox->cinfo.pOldProc = SubclassWindow(hwndframe, _colorwndproc);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3602 newbox->cinfo.fore = newbox->cinfo.back = -1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3603
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3604 SetWindowLong(hwndframe, GWL_USERDATA, (ULONG)newbox);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3605 return hwndframe;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3606 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3607
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3608 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3609 * Create a new Group Box to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3610 * Parameters:
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
3611 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3612 * pad: Number of pixels to pad around the box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3613 * title: Text to be displayined in the group outline.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3614 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3615 HWND API dw_groupbox_new(int type, int pad, char *title)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3616 {
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
3617 Box *newbox = calloc(sizeof(Box), 1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3618 HWND hwndframe;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3619
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3620 newbox->pad = pad;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3621 newbox->type = type;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3622 newbox->count = 0;
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
3623 newbox->cinfo.fore = newbox->cinfo.back = -1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3624
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3625 hwndframe = CreateWindow(FRAMECLASSNAME,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3626 "",
107
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 106
diff changeset
3627 WS_VISIBLE | WS_CHILD,
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3628 0,0,2000,1000,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3629 DW_HWND_OBJECT,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3630 NULL,
109
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
3631 DWInstance,
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3632 NULL);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3633
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3634 newbox->grouphwnd = CreateWindow(BUTTONCLASSNAME,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3635 title,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3636 WS_CHILD | BS_GROUPBOX |
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3637 WS_VISIBLE | WS_CLIPCHILDREN,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3638 0,0,2000,1000,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3639 hwndframe,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3640 NULL,
109
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
3641 DWInstance,
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3642 NULL);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3643
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3644 SetWindowLong(hwndframe, GWL_USERDATA, (ULONG)newbox);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3645 dw_window_set_font(newbox->grouphwnd, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3646 return hwndframe;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3647 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3648
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3649 /*
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3650 * Create a new MDI Frame to be packed.
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3651 * Parameters:
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3652 * id: An ID to be used with dw_window_from_id or 0L.
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3653 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3654 HWND API dw_mdi_new(unsigned long id)
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3655 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3656 CLIENTCREATESTRUCT ccs;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3657 HWND hwndframe;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3658
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3659 ccs.hWindowMenu = NULL;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3660 ccs.idFirstChild = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3661
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3662 hwndframe = CreateWindow("MDICLIENT",
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3663 "",
107
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 106
diff changeset
3664 WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS,
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3665 0,0,2000,1000,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3666 DW_HWND_OBJECT,
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 118
diff changeset
3667 (HMENU)id,
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3668 DWInstance,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3669 &ccs);
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3670 return hwndframe;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3671 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3672
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3673 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3674 * Create a bitmap object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3675 * Parameters:
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3676 * id: An ID to be used with dw_window_from_id or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3677 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3678 HWND API dw_bitmap_new(ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3679 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3680 return CreateWindow(STATICCLASSNAME,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3681 "",
107
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 106
diff changeset
3682 SS_BITMAP | WS_VISIBLE |
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 106
diff changeset
3683 WS_CHILD | WS_CLIPCHILDREN,
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3684 0,0,2000,1000,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3685 DW_HWND_OBJECT,
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 118
diff changeset
3686 (HMENU)id,
109
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
3687 DWInstance,
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3688 NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3689 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3690
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3691 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3692 * Create a notebook object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3693 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3694 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3695 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3696 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3697 HWND API dw_notebook_new(ULONG id, int top)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3698 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3699 ULONG flags = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3700 HWND tmp;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3701 NotebookPage **array = calloc(256, sizeof(NotebookPage *));
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3702
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3703 if(!top)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3704 flags = TCS_BOTTOM;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3705
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3706 tmp = CreateWindow(WC_TABCONTROL,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3707 "",
107
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 106
diff changeset
3708 WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN,
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3709 0,0,2000,1000,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3710 DW_HWND_OBJECT,
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 118
diff changeset
3711 (HMENU)id,
109
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
3712 DWInstance,
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3713 NULL);
191
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
3714 dw_window_set_data(tmp, "_dw_array", (void *)array);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3715 dw_window_set_font(tmp, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3716 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3717 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3718
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3719 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3720 * Create a menu object to be popped up.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3721 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3722 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3723 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3724 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3725 HMENUI API dw_menu_new(ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3726 {
238
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3727 return (HMENUI)CreatePopupMenu();
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3728 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3729
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3730 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3731 * Create a menubar on a window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3732 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3733 * location: Handle of a window frame to be attached to.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3734 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3735 HMENUI API dw_menubar_new(HWND location)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3736 {
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 182
diff changeset
3737 HMENUI tmp;
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 182
diff changeset
3738
238
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3739 tmp = (HMENUI)CreateMenu();
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3740
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3741 dw_window_set_data(location, "_dw_menu", (void *)tmp);
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3742
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3743 SetMenu(location, (HMENU)tmp);
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3744 return location;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3745 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3746
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3747 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3748 * Destroys a menu created with dw_menubar_new or dw_menu_new.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3749 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3750 * menu: Handle of a menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3751 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3752 void API dw_menu_destroy(HMENUI *menu)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3753 {
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 182
diff changeset
3754 if(menu)
238
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3755 {
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3756 HMENU mymenu = (HMENU)*menu;
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3757
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3758 if(IsWindow((HWND)mymenu) && !IsMenu(mymenu))
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3759 mymenu = (HMENU)dw_window_get_data((HWND)mymenu, "_dw_menu");
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3760 if(IsMenu(mymenu))
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3761 DestroyMenu(mymenu);
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3762 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3763 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3764
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3765 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3766 * Adds a menuitem or submenu to an existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3767 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3768 * menu: The handle the the existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3769 * title: The title text on the menu item to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3770 * id: An ID to be used for message passing.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3771 * end: If TRUE memu is positioned at the end of the menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3772 * check: If TRUE menu is "check"able.
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3773 * flags: Extended attributes to set on the menu.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3774 * submenu: Handle to an existing menu to be a submenu or NULL.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3775 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3776 HWND API dw_menu_append_item(HMENUI menux, char *title, ULONG id, ULONG flags, int end, int check, HMENUI submenu)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3777 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3778 MENUITEMINFO mii;
238
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3779 HMENU mymenu = (HMENU)menux;
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3780
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3781 if(IsWindow(menux) && !IsMenu(mymenu))
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3782 mymenu = (HMENU)dw_window_get_data(menux, "_dw_menu");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3783
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3784 mii.cbSize = sizeof(MENUITEMINFO);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3785 mii.fMask = MIIM_ID | MIIM_SUBMENU | MIIM_TYPE;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3786
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3787 /* Convert from OS/2 style accellerators to Win32 style */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3788 if(title)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3789 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3790 char *tmp = title;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3791
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3792 while(*tmp)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3793 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3794 if(*tmp == '~')
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3795 *tmp = '&';
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3796 tmp++;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3797 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3798 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3799
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3800 if(title && *title)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3801 mii.fType = MFT_STRING;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3802 else
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3803 mii.fType = MFT_SEPARATOR;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3804
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3805 mii.wID = id;
238
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3806 if(IsMenu((HMENU)submenu))
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3807 mii.hSubMenu = (HMENU)submenu;
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3808 else
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3809 mii.hSubMenu = 0;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3810 mii.dwTypeData = title;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3811 mii.cch = strlen(title);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3812
238
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3813 InsertMenuItem(mymenu, 65535, TRUE, &mii);
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3814 if(IsWindow(menux) && !IsMenu((HMENU)menux))
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3815 DrawMenuBar(menux);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3816 return (HWND)id;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3817 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3818
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3819 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3820 * Sets the state of a menu item check.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3821 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3822 * menu: The handle the the existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3823 * id: Menuitem id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3824 * check: TRUE for checked FALSE for not checked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3825 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3826 void API dw_menu_item_set_check(HMENUI menux, unsigned long id, int check)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3827 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3828 MENUITEMINFO mii;
238
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3829 HMENU mymenu = (HMENU)menux;
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3830
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3831 if(IsWindow(menux) && !IsMenu(mymenu))
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3832 mymenu = (HMENU)dw_window_get_data(menux, "_dw_menu");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3833
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3834 mii.cbSize = sizeof(MENUITEMINFO);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3835 mii.fMask = MIIM_STATE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3836 if(check)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3837 mii.fState = MFS_CHECKED;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3838 else
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3839 mii.fState = MFS_UNCHECKED;
238
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3840 SetMenuItemInfo(mymenu, id, FALSE, &mii);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3841 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3842
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3843 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3844 * Pops up a context menu at given x and y coordinates.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3845 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3846 * menu: The handle the the existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3847 * parent: Handle to the window initiating the popup.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3848 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3849 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3850 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3851 void API dw_menu_popup(HMENUI *menu, HWND parent, int x, int y)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3852 {
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 182
diff changeset
3853 if(menu)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3854 {
238
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3855 HMENU mymenu = (HMENU)*menu;
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3856
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3857 if(IsWindow(*menu) && !IsMenu(mymenu))
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3858 mymenu = (HMENU)dw_window_get_data(*menu, "_dw_menu");
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3859
93
98cce029a611 Changed handling of menu item click events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 90
diff changeset
3860 popup = parent;
238
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3861 TrackPopupMenu(mymenu, 0, x, y, 0, parent, NULL);
13d3de3f1e83 Rewrote the menu code to not return structs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 211
diff changeset
3862 DestroyMenu(mymenu);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3863 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3864 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3865
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3866
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3867 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3868 * Create a container object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3869 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3870 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3871 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3872 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3873 HWND API dw_container_new(ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3874 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3875 HWND tmp = CreateWindow(WC_LISTVIEW,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3876 "",
107
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 106
diff changeset
3877 WS_VISIBLE | WS_CHILD |
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 106
diff changeset
3878 LVS_REPORT | LVS_SHOWSELALWAYS |
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3879 LVS_SHAREIMAGELISTS | WS_BORDER |
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3880 WS_CLIPCHILDREN,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3881 0,0,2000,1000,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3882 DW_HWND_OBJECT,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3883 (HMENU)id,
109
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
3884 DWInstance,
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3885 NULL);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3886 ContainerInfo *cinfo = (ContainerInfo *)calloc(1, sizeof(ContainerInfo));
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3887
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3888 if(!cinfo)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3889 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3890 DestroyWindow(tmp);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3891 return NULL;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3892 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3893
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3894 cinfo->pOldProc = (WNDPROC)SubclassWindow(tmp, _containerwndproc);
68
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3895 cinfo->cinfo.fore = cinfo->cinfo.back = -1;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3896
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3897 SetWindowLong(tmp, GWL_USERDATA, (ULONG)cinfo);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3898 dw_window_set_font(tmp, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3899 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3900 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3901
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3902 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3903 * Create a tree object to be packed.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3904 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3905 * id: An ID to be used for getting the resource from the
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3906 * resource file.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3907 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3908 HWND API dw_tree_new(ULONG id)
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3909 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3910 HWND tmp = CreateWindow(WC_TREEVIEW,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3911 "",
107
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 106
diff changeset
3912 WS_VISIBLE | WS_CHILD |
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 106
diff changeset
3913 TVS_HASLINES | TVS_SHOWSELALWAYS |
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3914 TVS_HASBUTTONS | TVS_LINESATROOT |
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3915 WS_BORDER | WS_CLIPCHILDREN,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3916 0,0,2000,1000,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3917 DW_HWND_OBJECT,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3918 (HMENU)id,
109
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
3919 DWInstance,
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3920 NULL);
68
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3921 ContainerInfo *cinfo = (ContainerInfo *)calloc(1, sizeof(ContainerInfo));
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3922 TreeView_SetItemHeight(tmp, 16);
68
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3923
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3924 if(!cinfo)
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3925 {
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3926 DestroyWindow(tmp);
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3927 return NULL;
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3928 }
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3929
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3930 cinfo->pOldProc = (WNDPROC)SubclassWindow(tmp, _treewndproc);
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3931 cinfo->cinfo.fore = cinfo->cinfo.back = -1;
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3932
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3933 SetWindowLong(tmp, GWL_USERDATA, (ULONG)cinfo);
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3934 dw_window_set_font(tmp, DefaultFont);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3935 return tmp;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3936 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3937
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
3938 /*
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3939 * Returns the current X and Y coordinates of the mouse pointer.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3940 * Parameters:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3941 * x: Pointer to variable to store X coordinate.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3942 * y: Pointer to variable to store Y coordinate.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3943 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3944 void API dw_pointer_query_pos(long *x, long *y)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3945 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3946 POINT ptl;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3947
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3948 GetCursorPos(&ptl);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3949 if(x && y)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3950 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3951 *x = ptl.x;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3952 *y = ptl.y;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3953 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3954 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3955
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3956 /*
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3957 * Sets the X and Y coordinates of the mouse pointer.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3958 * Parameters:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3959 * x: X coordinate.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3960 * y: Y coordinate.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3961 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3962 void API dw_pointer_set_pos(long x, long y)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3963 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3964 SetCursorPos(x, y);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3965 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3966
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3967 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3968 * Create a new static text window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3969 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3970 * text: The text to be display by the static text widget.
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
3971 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3972 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3973 HWND API dw_text_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3974 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3975 HWND tmp = CreateWindow(STATICCLASSNAME,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3976 text,
107
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 106
diff changeset
3977 BS_TEXT | WS_VISIBLE |
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 106
diff changeset
3978 WS_CHILD | WS_CLIPCHILDREN,
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3979 0,0,2000,1000,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3980 DW_HWND_OBJECT,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3981 (HMENU)id,
109
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
3982 DWInstance,
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3983 NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3984 dw_window_set_font(tmp, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3985 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3986 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3987
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3988 /*
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3989 * Create a new status text window (widget) to be packed.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3990 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3991 * text: The text to be display by the static text widget.
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
3992 * id: An ID to be used with dw_window_from_id() or 0L.
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3993 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3994 HWND API dw_status_text_new(char *text, ULONG id)
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3995 {
299
2a97f8d9b297 Use DrawStatusText() to make the status lines, instead of doing it ourself.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 298
diff changeset
3996 HWND tmp = CreateWindow(ObjectClassName,
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3997 text,
107
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 106
diff changeset
3998 BS_TEXT | WS_VISIBLE |
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 106
diff changeset
3999 WS_CHILD | WS_CLIPCHILDREN,
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4000 0,0,2000,1000,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4001 DW_HWND_OBJECT,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4002 (HMENU)id,
109
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
4003 DWInstance,
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4004 NULL);
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4005 dw_window_set_font(tmp, DefaultFont);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4006 SubclassWindow(tmp, _statuswndproc);
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4007 return tmp;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4008 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4009
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4010 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4011 * Create a new Multiline Editbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4012 * Parameters:
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4013 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4014 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4015 HWND API dw_mle_new(ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4016 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4017
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4018 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE,
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4019 EDITCLASSNAME,
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4020 "",
107
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 106
diff changeset
4021 WS_VISIBLE | WS_BORDER |
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4022 WS_VSCROLL | ES_MULTILINE |
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4023 ES_WANTRETURN | WS_CHILD |
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4024 WS_CLIPCHILDREN,
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4025 0,0,2000,1000,
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4026 DW_HWND_OBJECT,
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4027 (HMENU)id,
109
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
4028 DWInstance,
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4029 NULL);
68
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4030 ContainerInfo *cinfo = (ContainerInfo *)calloc(1, sizeof(ContainerInfo));
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4031
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4032 if(!cinfo)
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4033 {
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4034 DestroyWindow(tmp);
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4035 return NULL;
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4036 }
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4037
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4038 cinfo->pOldProc = (WNDPROC)SubclassWindow(tmp, _treewndproc);
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4039 cinfo->cinfo.fore = cinfo->cinfo.back = -1;
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4040
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4041 SetWindowLong(tmp, GWL_USERDATA, (ULONG)cinfo);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4042 dw_window_set_font(tmp, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4043 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4044 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4045
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4046 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4047 * Create a new Entryfield window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4048 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4049 * text: The default text to be in the entryfield widget.
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4050 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4051 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4052 HWND API dw_entryfield_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4053 {
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4054 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE,
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4055 EDITCLASSNAME,
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4056 text,
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4057 ES_WANTRETURN | WS_CHILD |
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4058 WS_BORDER | ES_AUTOHSCROLL |
107
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 106
diff changeset
4059 WS_VISIBLE | WS_CLIPCHILDREN,
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4060 0,0,2000,1000,
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4061 DW_HWND_OBJECT,
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4062 (HMENU)id,
109
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
4063 DWInstance,
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4064 NULL);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4065 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4066
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4067 cinfo->back = cinfo->fore = -1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4068
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4069 cinfo->pOldProc = SubclassWindow(tmp, _colorwndproc);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4070 SetWindowLong(tmp, GWL_USERDATA, (ULONG)cinfo);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4071 dw_window_set_font(tmp, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4072 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4073 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4074
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4075 /*
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4076 * Create a new Entryfield passwird window (widget) to be packed.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4077 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4078 * text: The default text to be in the entryfield widget.
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4079 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4080 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4081 HWND API dw_entryfield_password_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4082 {
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4083 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE,
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4084 EDITCLASSNAME,
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4085 text,
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4086 ES_WANTRETURN | WS_CHILD |
107
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 106
diff changeset
4087 ES_PASSWORD | WS_BORDER | WS_VISIBLE |
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4088 ES_AUTOHSCROLL | WS_CLIPCHILDREN,
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4089 0,0,2000,1000,
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4090 DW_HWND_OBJECT,
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4091 (HMENU)id,
109
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
4092 DWInstance,
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4093 NULL);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4094 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4095
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4096 cinfo->back = cinfo->fore = -1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4097
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4098 cinfo->pOldProc = SubclassWindow(tmp, _colorwndproc);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4099 SetWindowLong(tmp, GWL_USERDATA, (ULONG)cinfo);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4100 dw_window_set_font(tmp, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4101 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4102 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4103
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4104 BOOL CALLBACK _subclass_child(HWND handle, LPARAM lp)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4105 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4106 ColorInfo *cinfo = (ColorInfo *)lp;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4107
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4108 if(cinfo)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4109 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4110 cinfo->buddy = handle;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4111 cinfo->pOldProc = (WNDPROC)SubclassWindow(handle, _colorwndproc);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4112 SetWindowLong(handle, GWL_USERDATA, (ULONG)cinfo);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4113 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4114 return FALSE;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4115 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4116
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4117 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4118 * Create a new Combobox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4119 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4120 * text: The default text to be in the combpbox widget.
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4121 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4122 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4123 HWND API dw_combobox_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4124 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4125 HWND tmp = CreateWindow(COMBOBOXCLASSNAME,
89
ec311fe773da Include a vertical scrollbar on comboboxes when there are too many items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 88
diff changeset
4126 text,
ec311fe773da Include a vertical scrollbar on comboboxes when there are too many items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 88
diff changeset
4127 WS_CHILD | CBS_DROPDOWN | WS_VSCROLL |
194
37bee5b50bcb Comboboxes need the CBS_AUTOHSCROLL style on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 191
diff changeset
4128 WS_CLIPCHILDREN | CBS_AUTOHSCROLL | WS_VISIBLE,
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4129 0,0,2000,1000,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4130 DW_HWND_OBJECT,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4131 (HMENU)id,
109
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
4132 DWInstance,
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4133 NULL);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4134 ColorInfo *cinfo = (ColorInfo *)calloc(1, sizeof(ColorInfo));
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4135 ColorInfo *cinfo2 = (ColorInfo *)calloc(1, sizeof(ColorInfo));
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4136
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
4137 if(!cinfo || !cinfo2)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4138 {
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
4139 if(cinfo)
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
4140 free(cinfo);
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
4141 if(cinfo2)
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
4142 free(cinfo2);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4143 DestroyWindow(tmp);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4144 return NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4145 }
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4146
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4147 cinfo2->fore = cinfo->fore = -1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4148 cinfo2->back = cinfo->back = -1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4149 cinfo2->combo = cinfo->combo = tmp;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4150 EnumChildWindows(tmp, _subclass_child, (LPARAM)cinfo2);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4151
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4152 SetWindowLong(tmp, GWL_USERDATA, (ULONG)cinfo);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4153 dw_window_set_font(tmp, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4154 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4155 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4156
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4157 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4158 * Create a new button window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4159 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4160 * text: The text to be display by the static text widget.
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4161 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4162 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4163 HWND API dw_button_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4164 {
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
4165 BubbleButton *bubble = calloc(1, sizeof(BubbleButton));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4166
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4167 HWND tmp = CreateWindow(BUTTONCLASSNAME,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4168 text,
107
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 106
diff changeset
4169 WS_CHILD | BS_PUSHBUTTON |
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 106
diff changeset
4170 WS_VISIBLE | WS_CLIPCHILDREN,
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4171 0,0,2000,1000,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4172 DW_HWND_OBJECT,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4173 (HMENU)id,
109
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
4174 DWInstance,
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4175 NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4176
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4177 bubble->id = id;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4178 bubble->bubbletext[0] = '\0';
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4179 bubble->pOldProc = (WNDPROC)SubclassWindow(tmp, _BtProc);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4180
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4181 SetWindowLong(tmp, GWL_USERDATA, (ULONG)bubble);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4182 dw_window_set_font(tmp, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4183 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4184 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4185
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4186 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4187 * Create a new bitmap button window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4188 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4189 * text: Bubble help text to be displayed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4190 * id: An ID of a bitmap in the resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4191 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4192 HWND API dw_bitmapbutton_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4193 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4194 HWND tmp;
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
4195 BubbleButton *bubble = calloc(1, sizeof(BubbleButton));
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4196 HBITMAP hbitmap = LoadBitmap(DWInstance, MAKEINTRESOURCE(id));
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4197
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4198 tmp = CreateWindow(BUTTONCLASSNAME,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4199 "",
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4200 WS_CHILD | BS_PUSHBUTTON |
107
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 106
diff changeset
4201 BS_BITMAP | WS_CLIPCHILDREN |
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 106
diff changeset
4202 WS_VISIBLE,
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4203 0,0,2000,1000,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4204 DW_HWND_OBJECT,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4205 (HMENU)id,
109
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
4206 DWInstance,
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4207 NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4208
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4209 bubble->id = id;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4210 strncpy(bubble->bubbletext, text, BUBBLE_HELP_MAX - 1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4211 bubble->bubbletext[BUBBLE_HELP_MAX - 1] = '\0';
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4212 bubble->pOldProc = (WNDPROC)SubclassWindow(tmp, _BtProc);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4213
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4214 SetWindowLong(tmp, GWL_USERDATA, (ULONG)bubble);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4215
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4216 SendMessage(tmp, BM_SETIMAGE,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4217 (WPARAM) IMAGE_BITMAP,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4218 (LPARAM) hbitmap);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4219 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4220 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4221
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4222 /*
281
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4223 * Create a new bitmap button window (widget) to be packed from a file.
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4224 * Parameters:
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4225 * text: Bubble help text to be displayed.
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4226 * id: An ID to be used with dw_window_from_id() or 0L.
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4227 * filename: Name of the file, omit extention to have
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4228 * DW pick the appropriate file extension.
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4229 * (BMP on OS/2 or Windows, XPM on Unix)
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4230 */
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4231 HWND dw_bitmapbutton_new_from_file(char *text, unsigned long id, char *filename)
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4232 {
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4233 HWND tmp;
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4234 BubbleButton *bubble;
303
464b5e46b313 Create the bitmap button even if the bitmap file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 301
diff changeset
4235 HBITMAP hbitmap = 0;
281
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4236 char *file = malloc(strlen(filename) + 5);
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4237
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4238 if(!file || !(bubble = calloc(1, sizeof(BubbleButton))))
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4239 {
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4240 if(file)
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4241 free(file);
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4242 return 0;
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4243 }
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4244
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4245 tmp = CreateWindow(BUTTONCLASSNAME,
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4246 "",
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4247 WS_CHILD | BS_PUSHBUTTON |
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4248 BS_BITMAP | WS_CLIPCHILDREN |
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4249 WS_VISIBLE,
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4250 0,0,2000,1000,
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4251 DW_HWND_OBJECT,
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4252 (HMENU)id,
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4253 DWInstance,
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4254 NULL);
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4255
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4256 bubble->id = id;
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4257 strncpy(bubble->bubbletext, text, BUBBLE_HELP_MAX - 1);
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4258 bubble->bubbletext[BUBBLE_HELP_MAX - 1] = '\0';
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4259 bubble->pOldProc = (WNDPROC)SubclassWindow(tmp, _BtProc);
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4260
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4261 SetWindowLong(tmp, GWL_USERDATA, (ULONG)bubble);
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4262
303
464b5e46b313 Create the bitmap button even if the bitmap file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 301
diff changeset
4263 strcpy(file, filename);
464b5e46b313 Create the bitmap button even if the bitmap file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 301
diff changeset
4264
464b5e46b313 Create the bitmap button even if the bitmap file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 301
diff changeset
4265 /* check if we can read from this file (it exists and read permission) */
464b5e46b313 Create the bitmap button even if the bitmap file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 301
diff changeset
4266 if(access(file, 04) == 0)
464b5e46b313 Create the bitmap button even if the bitmap file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 301
diff changeset
4267 hbitmap = (HBITMAP)LoadImage(NULL, file, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
464b5e46b313 Create the bitmap button even if the bitmap file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 301
diff changeset
4268 else
464b5e46b313 Create the bitmap button even if the bitmap file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 301
diff changeset
4269 {
464b5e46b313 Create the bitmap button even if the bitmap file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 301
diff changeset
4270 /* Try with .bmp extention */
464b5e46b313 Create the bitmap button even if the bitmap file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 301
diff changeset
4271 strcat(file, ".bmp");
464b5e46b313 Create the bitmap button even if the bitmap file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 301
diff changeset
4272 if(access(file, 04) == 0)
464b5e46b313 Create the bitmap button even if the bitmap file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 301
diff changeset
4273 hbitmap = (HBITMAP)LoadImage(NULL, file, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
464b5e46b313 Create the bitmap button even if the bitmap file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 301
diff changeset
4274 }
464b5e46b313 Create the bitmap button even if the bitmap file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 301
diff changeset
4275
464b5e46b313 Create the bitmap button even if the bitmap file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 301
diff changeset
4276
464b5e46b313 Create the bitmap button even if the bitmap file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 301
diff changeset
4277 if(hbitmap)
464b5e46b313 Create the bitmap button even if the bitmap file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 301
diff changeset
4278 SendMessage(tmp, BM_SETIMAGE,
464b5e46b313 Create the bitmap button even if the bitmap file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 301
diff changeset
4279 (WPARAM) IMAGE_BITMAP,
464b5e46b313 Create the bitmap button even if the bitmap file does not exist.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 301
diff changeset
4280 (LPARAM) hbitmap);
281
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4281 free(file);
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4282 return tmp;
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4283 }
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4284
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
4285 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4286 * Create a new spinbutton window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4287 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4288 * text: The text to be display by the static text widget.
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4289 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4290 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4291 HWND API dw_spinbutton_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4292 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4293 ULONG *data = malloc(sizeof(ULONG));
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4294 HWND buddy = CreateWindowEx(WS_EX_CLIENTEDGE,
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4295 EDITCLASSNAME,
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4296 text,
107
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 106
diff changeset
4297 WS_CHILD | WS_BORDER | WS_VISIBLE |
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4298 ES_NUMBER | WS_CLIPCHILDREN,
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4299 0,0,2000,1000,
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4300 DW_HWND_OBJECT,
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4301 NULL,
109
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
4302 DWInstance,
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4303 NULL);
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4304 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE,
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4305 UPDOWN_CLASS,
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4306 NULL,
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4307 WS_CHILD | UDS_ALIGNRIGHT | WS_BORDER |
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4308 UDS_ARROWKEYS | UDS_SETBUDDYINT |
107
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 106
diff changeset
4309 UDS_WRAP | UDS_NOTHOUSANDS | WS_VISIBLE,
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4310 0,0,2000,1000,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4311 DW_HWND_OBJECT,
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4312 (HMENU)id,
109
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
4313 DWInstance,
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4314 NULL);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4315 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4316
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4317 SendMessage(tmp, UDM_SETBUDDY, (WPARAM)buddy, 0);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4318 cinfo->back = cinfo->fore = -1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4319 cinfo->buddy = tmp;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4320
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4321 cinfo->pOldProc = SubclassWindow(buddy, _colorwndproc);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4322 SetWindowLong(buddy, GWL_USERDATA, (ULONG)cinfo);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4323
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4324 cinfo = calloc(1, sizeof(ColorInfo));
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4325 cinfo->buddy = buddy;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4326 cinfo->pOldProc = SubclassWindow(tmp, _spinnerwndproc);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4327
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4328 SetWindowLong(tmp, GWL_USERDATA, (ULONG)cinfo);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4329 dw_window_set_font(buddy, DefaultFont);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4330 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4331 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4332
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4333 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4334 * Create a new radiobutton window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4335 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4336 * text: The text to be display by the static text widget.
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4337 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4338 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4339 HWND API dw_radiobutton_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4340 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4341 HWND tmp = CreateWindow(BUTTONCLASSNAME,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4342 text,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4343 WS_CHILD | BS_AUTORADIOBUTTON |
107
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 106
diff changeset
4344 WS_CLIPCHILDREN | WS_VISIBLE,
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4345 0,0,2000,1000,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4346 DW_HWND_OBJECT,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4347 (HMENU)id,
109
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
4348 DWInstance,
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4349 NULL);
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4350 BubbleButton *bubble = calloc(1, sizeof(BubbleButton));
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4351 bubble->id = id;
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4352 bubble->pOldProc = (WNDPROC)SubclassWindow(tmp, _BtProc);
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4353 bubble->cinfo.fore = -1;
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4354 bubble->cinfo.back = -1;
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4355 SetWindowLong(tmp, GWL_USERDATA, (ULONG)bubble);
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4356 dw_window_set_font(tmp, DefaultFont);
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4357 return tmp;
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4358 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4359
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4360
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4361 /*
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4362 * Create a new slider window (widget) to be packed.
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4363 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4364 * vertical: TRUE or FALSE if slider is vertical.
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4365 * increments: Number of increments available.
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4366 * id: An ID to be used with dw_window_from_id() or 0L.
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4367 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4368 HWND API dw_slider_new(int vertical, int increments, ULONG id)
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4369 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4370 HWND tmp = CreateWindow(TRACKBAR_CLASS,
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4371 "",
107
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 106
diff changeset
4372 WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE |
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4373 (vertical ? TBS_VERT : TBS_HORZ),
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4374 0,0,2000,1000,
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4375 DW_HWND_OBJECT,
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 118
diff changeset
4376 (HMENU)id,
109
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
4377 DWInstance,
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4378 NULL);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4379 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4380
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4381 cinfo->back = cinfo->fore = -1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4382
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4383 cinfo->pOldProc = SubclassWindow(tmp, _colorwndproc);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4384 SetWindowLong(tmp, GWL_USERDATA, (ULONG)cinfo);
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4385 SendMessage(tmp, TBM_SETRANGE, (WPARAM)FALSE, (LPARAM)MAKELONG(0, increments-1));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4386 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4387 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4388
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4389 /*
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
4390 * Create a new scrollbar window (widget) to be packed.
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
4391 * Parameters:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
4392 * vertical: TRUE or FALSE if scrollbar is vertical.
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
4393 * increments: Number of increments available.
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4394 * id: An ID to be used with dw_window_from_id() or 0L.
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
4395 */
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
4396 HWND API dw_scrollbar_new(int vertical, int increments, ULONG id)
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
4397 {
204
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
4398 HWND tmp = CreateWindow(SCROLLBARCLASSNAME,
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
4399 "",
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
4400 WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE |
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
4401 (vertical ? SBS_VERT : SBS_HORZ),
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
4402 0,0,2000,1000,
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
4403 DW_HWND_OBJECT,
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
4404 (HMENU)id,
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
4405 DWInstance,
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
4406 NULL);
204
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
4407 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
4408
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
4409 cinfo->back = cinfo->fore = -1;
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
4410
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
4411 cinfo->pOldProc = SubclassWindow(tmp, _colorwndproc);
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
4412 SetWindowLong(tmp, GWL_USERDATA, (ULONG)cinfo);
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
4413 dw_window_set_data(tmp, "_dw_scrollbar", (void *)1);
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
4414 return tmp;
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
4415 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
4416
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
4417 /*
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 32
diff changeset
4418 * Create a new percent bar window (widget) to be packed.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4419 * Parameters:
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4420 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4421 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4422 HWND API dw_percent_new(ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4423 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4424 return CreateWindow(PROGRESS_CLASS,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4425 "",
107
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 106
diff changeset
4426 WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN,
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4427 0,0,2000,1000,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4428 DW_HWND_OBJECT,
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 118
diff changeset
4429 (HMENU)id,
109
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
4430 DWInstance,
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4431 NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4432 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4433
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4434 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4435 * Create a new checkbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4436 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4437 * text: The text to be display by the static text widget.
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4438 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4439 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4440 HWND API dw_checkbox_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4441 {
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
4442 BubbleButton *bubble = calloc(1, sizeof(BubbleButton));
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4443 HWND tmp = CreateWindow(BUTTONCLASSNAME,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4444 text,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4445 WS_CHILD | BS_AUTOCHECKBOX |
107
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 106
diff changeset
4446 BS_TEXT | WS_CLIPCHILDREN | WS_VISIBLE,
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4447 0,0,2000,1000,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4448 DW_HWND_OBJECT,
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 118
diff changeset
4449 (HMENU)id,
109
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
4450 DWInstance,
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4451 NULL);
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
4452 bubble->id = id;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
4453 bubble->checkbox = 1;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
4454 bubble->pOldProc = (WNDPROC)SubclassWindow(tmp, _BtProc);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
4455 bubble->cinfo.fore = -1;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
4456 bubble->cinfo.back = -1;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
4457 SetWindowLong(tmp, GWL_USERDATA, (ULONG)bubble);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4458 dw_window_set_font(tmp, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4459 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4460 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4461
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4462 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4463 * Create a new listbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4464 * Parameters:
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4465 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4466 * multi: Multiple select TRUE or FALSE.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4467 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4468 HWND API dw_listbox_new(ULONG id, int multi)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4469 {
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
4470 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE,
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
4471 LISTBOXCLASSNAME,
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
4472 "",
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
4473 WS_VISIBLE | LBS_NOINTEGRALHEIGHT |
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
4474 WS_CHILD | LBS_HASSTRINGS |
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
4475 LBS_NOTIFY | WS_BORDER | WS_CLIPCHILDREN |
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
4476 WS_VSCROLL | (multi ? LBS_MULTIPLESEL : 0) ,
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
4477 0,0,2000,1000,
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
4478 DW_HWND_OBJECT,
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
4479 (HMENU)id,
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
4480 DWInstance,
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
4481 NULL);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4482 ContainerInfo *cinfo = (ContainerInfo *)calloc(1, sizeof(ContainerInfo));
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4483
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4484 if(!cinfo)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4485 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4486 DestroyWindow(tmp);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4487 return NULL;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4488 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4489
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4490 cinfo->cinfo.fore = -1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4491 cinfo->cinfo.back = -1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4492 cinfo->pOldProc = (WNDPROC)SubclassWindow(tmp, _containerwndproc);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4493
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4494 SetWindowLong(tmp, GWL_USERDATA, (ULONG)cinfo);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4495 dw_window_set_font(tmp, DefaultFont);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4496 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4497 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4498
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4499 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4500 * Sets the icon used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4501 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4502 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4503 * id: An ID to be used to specify the icon.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4504 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4505 void API dw_window_set_icon(HWND handle, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4506 {
336
a2f72b5d5d0a Minor change to dw_window_set_icon() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 334
diff changeset
4507 HICON hicon = id < 65536 ? LoadIcon(DWInstance, MAKEINTRESOURCE(id)) : (HICON)id;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4508
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4509 SendMessage(handle, WM_SETICON,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4510 (WPARAM) IMAGE_ICON,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4511 (LPARAM) hicon);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4512 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4513
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4514 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4515 * Sets the bitmap used for a given static window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4516 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4517 * handle: Handle to the window.
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4518 * id: An ID to be used to specify the icon,
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4519 * (pass 0 if you use the filename param)
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4520 * filename: a path to a file (Bitmap on OS/2 or
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4521 * Windows and a pixmap on Unix, pass
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4522 * NULL if you use the id param)
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4523 */
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4524 void API dw_window_set_bitmap(HWND handle, unsigned long id, char *filename)
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4525 {
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4526 HBITMAP hbitmap;
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4527 HBITMAP oldbitmap = (HBITMAP)SendMessage(handle, STM_GETIMAGE, IMAGE_BITMAP, 0);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4528
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4529 if(id)
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4530 hbitmap = LoadBitmap(DWInstance, MAKEINTRESOURCE(id));
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4531 else if(filename)
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4532 {
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4533 char *file = malloc(strlen(filename) + 5);
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4534
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4535 if (!file)
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4536 return;
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4537
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4538 strcpy(file, filename);
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4539
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4540 /* check if we can read from this file (it exists and read permission) */
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4541 if(access(file, 04) != 0)
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4542 {
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4543 /* Try with .bmp extention */
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4544 strcat(file, ".bmp");
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4545 if(access(file, 04) != 0)
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4546 {
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4547 free(file);
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4548 return;
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4549 }
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4550 }
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4551
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4552 hbitmap = (HBITMAP)LoadImage(NULL, file, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4553 free(file);
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4554 }
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4555 else
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4556 return;
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
4557
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4558 SendMessage(handle, STM_SETIMAGE,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4559 (WPARAM) IMAGE_BITMAP,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4560 (LPARAM) hbitmap);
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4561
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4562 if(oldbitmap)
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4563 DeleteObject(oldbitmap);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4564 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4565
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4566 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4567 * Sets the text used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4568 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4569 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4570 * text: The text associsated with a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4571 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4572 void API dw_window_set_text(HWND handle, char *text)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4573 {
75
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
4574 char tmpbuf[100];
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
4575
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
4576 GetClassName(handle, tmpbuf, 99);
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
4577
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4578 SetWindowText(handle, text);
75
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
4579
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
4580 /* Combobox */
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
4581 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0)
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
4582 SendMessage(handle, CB_SETEDITSEL, 0, MAKELPARAM(-1, 0));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4583 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4584
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4585 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4586 * Gets the text used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4587 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4588 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4589 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4590 * text: The text associsated with a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4591 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4592 char * API dw_window_get_text(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4593 {
173
c2b5d0019ec3 Updated dw_window_get_text() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 168
diff changeset
4594 int len = GetWindowTextLength(handle);
c2b5d0019ec3 Updated dw_window_get_text() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 168
diff changeset
4595 char *tempbuf = calloc(1, len + 2);
c2b5d0019ec3 Updated dw_window_get_text() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 168
diff changeset
4596
c2b5d0019ec3 Updated dw_window_get_text() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 168
diff changeset
4597 GetWindowText(handle, tempbuf, len + 1);
c2b5d0019ec3 Updated dw_window_get_text() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 168
diff changeset
4598
c2b5d0019ec3 Updated dw_window_get_text() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 168
diff changeset
4599 return tempbuf;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4600 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4601
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4602 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4603 * Disables given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4604 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4605 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4606 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4607 void API dw_window_disable(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4608 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4609 EnableWindow(handle, FALSE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4610 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4611
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4612 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4613 * Enables given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4614 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4615 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4616 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4617 void API dw_window_enable(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4618 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4619 EnableWindow(handle, TRUE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4620 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4621
247
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
4622 static HWND _dw_wfid_hwnd = NULL;
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
4623
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
4624 BOOL CALLBACK _wfid(HWND handle, LPARAM lParam)
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
4625 {
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
4626 if(GetWindowLong(handle, GWL_ID) == lParam)
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
4627 {
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
4628 _dw_wfid_hwnd = handle;
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
4629 return FALSE;
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
4630 }
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
4631 return TRUE;
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
4632 }
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
4633
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4634 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4635 * Gets the child window handle with specified ID.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4636 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4637 * handle: Handle to the parent window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4638 * id: Integer ID of the child.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4639 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4640 HWND API dw_window_from_id(HWND handle, int id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4641 {
247
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
4642 _dw_wfid_hwnd = NULL;
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
4643 EnumChildWindows(handle, _wfid, (LPARAM)id);
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
4644 return _dw_wfid_hwnd;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4645 }
248
0f9a185deeb6 Minor change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 247
diff changeset
4646
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4647 /*
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4648 * Pack windows (widgets) into a box from the start (or top).
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4649 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4650 * box: Window handle of the box to be packed into.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4651 * item: Window handle of the item to be back.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4652 * width: Width in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4653 * height: Height in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4654 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4655 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4656 * pad: Number of pixels of padding around the item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4657 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4658 void API dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4659 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4660 Box *thisbox;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4661
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4662 thisbox = (Box *)GetWindowLong(box, GWL_USERDATA);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4663 if(thisbox)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4664 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4665 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4666 Item *tmpitem, *thisitem = thisbox->items;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4667 char tmpbuf[100];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4668
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
4669 tmpitem = malloc(sizeof(Item)*(thisbox->count+1));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4670
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4671 for(z=0;z<thisbox->count;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4672 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4673 tmpitem[z] = thisitem[z];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4674 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4675
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4676 GetClassName(item, tmpbuf, 99);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4677
298
caed245ea8a1 Sanity check, if expand is set width/height can't be zero... force it to 1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 295
diff changeset
4678 if(vsize && !height)
caed245ea8a1 Sanity check, if expand is set width/height can't be zero... force it to 1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 295
diff changeset
4679 height = 1;
caed245ea8a1 Sanity check, if expand is set width/height can't be zero... force it to 1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 295
diff changeset
4680 if(hsize && !width)
caed245ea8a1 Sanity check, if expand is set width/height can't be zero... force it to 1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 295
diff changeset
4681 width = 1;
caed245ea8a1 Sanity check, if expand is set width/height can't be zero... force it to 1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 295
diff changeset
4682
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4683 if(strnicmp(tmpbuf, FRAMECLASSNAME, 2)==0)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4684 tmpitem[thisbox->count].type = TYPEBOX;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4685 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4686 tmpitem[thisbox->count].type = TYPEITEM;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4687
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4688 tmpitem[thisbox->count].hwnd = item;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4689 tmpitem[thisbox->count].origwidth = tmpitem[thisbox->count].width = width;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4690 tmpitem[thisbox->count].origheight = tmpitem[thisbox->count].height = height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4691 tmpitem[thisbox->count].pad = pad;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4692 if(hsize)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4693 tmpitem[thisbox->count].hsize = SIZEEXPAND;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4694 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4695 tmpitem[thisbox->count].hsize = SIZESTATIC;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4696
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4697 if(vsize)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4698 tmpitem[thisbox->count].vsize = SIZEEXPAND;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4699 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4700 tmpitem[thisbox->count].vsize = SIZESTATIC;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4701
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4702 thisbox->items = tmpitem;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4703
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4704 if(thisbox->count)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4705 free(thisitem);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4706
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4707 thisbox->count++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4708
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4709 SetParent(item, box);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4710 if(strncmp(tmpbuf, UPDOWN_CLASS, strlen(UPDOWN_CLASS))==0)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4711 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4712 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(item, GWL_USERDATA);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4713
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4714 if(cinfo)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4715 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4716 SetParent(cinfo->buddy, box);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4717 ShowWindow(cinfo->buddy, SW_SHOW);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4718 SendMessage(item, UDM_SETBUDDY, (WPARAM)cinfo->buddy, 0);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4719 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4720 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4721 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4722 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4723
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4724 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4725 * Sets the size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4726 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4727 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4728 * width: New width in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4729 * height: New height in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4730 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4731 void API dw_window_set_usize(HWND handle, ULONG width, ULONG height)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4732 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4733 SetWindowPos(handle, (HWND)NULL, 0, 0, width, height, SWP_SHOWWINDOW | SWP_NOZORDER | SWP_NOMOVE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4734 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4735
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4736 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4737 * Returns the width of the screen.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4738 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4739 int API dw_screen_width(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4740 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4741 return GetSystemMetrics(SM_CXSCREEN);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4742 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4743
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4744 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4745 * Returns the height of the screen.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4746 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4747 int API dw_screen_height(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4748 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4749 return GetSystemMetrics(SM_CYSCREEN);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4750 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4751
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4752 /* This should return the current color depth */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4753 unsigned long API dw_color_depth(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4754 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4755 int bpp;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4756 HDC hdc = GetDC(HWND_DESKTOP);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4757
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4758 bpp = GetDeviceCaps(hdc, BITSPIXEL);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4759
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4760 ReleaseDC(HWND_DESKTOP, hdc);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4761
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4762 return bpp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4763 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4764
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4765
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4766 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4767 * Sets the position of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4768 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4769 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4770 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4771 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4772 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4773 void API dw_window_set_pos(HWND handle, ULONG x, ULONG y)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4774 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4775 SetWindowPos(handle, (HWND)NULL, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4776 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4777
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4778 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4779 * Sets the position and size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4780 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4781 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4782 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4783 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4784 * width: Width of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4785 * height: Height of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4786 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4787 void API dw_window_set_pos_size(HWND handle, ULONG x, ULONG y, ULONG width, ULONG height)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4788 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4789 SetWindowPos(handle, (HWND)NULL, x, y, width, height, SWP_NOZORDER | SWP_SHOWWINDOW | SWP_NOACTIVATE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4790 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4791
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4792 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4793 * Gets the position and size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4794 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4795 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4796 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4797 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4798 * width: Width of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4799 * height: Height of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4800 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4801 void API dw_window_get_pos_size(HWND handle, ULONG *x, ULONG *y, ULONG *width, ULONG *height)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4802 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4803 WINDOWPLACEMENT wp;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4804
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4805 wp.length = sizeof(WINDOWPLACEMENT);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4806
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4807 GetWindowPlacement(handle, &wp);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4808 if(x)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4809 *x = wp.rcNormalPosition.left;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4810 if(y)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4811 *y = wp.rcNormalPosition.top;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4812 if(width)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4813 *width = wp.rcNormalPosition.right - wp.rcNormalPosition.left;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4814 if(height)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4815 *height = wp.rcNormalPosition.bottom - wp.rcNormalPosition.top;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4816
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4817 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4818
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4819 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4820 * Sets the style of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4821 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4822 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4823 * width: New width in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4824 * height: New height in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4825 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4826 void API dw_window_set_style(HWND handle, ULONG style, ULONG mask)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4827 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4828 ULONG tmp, currentstyle = GetWindowLong(handle, GWL_STYLE);
88
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
4829 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4830
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4831 tmp = currentstyle | mask;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4832 tmp ^= mask;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4833 tmp |= style;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4834
88
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
4835
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
4836 /* We are using SS_NOPREFIX as a VCENTER flag */
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
4837 if(tmp & SS_NOPREFIX)
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
4838 {
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
4839
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
4840 if(cinfo)
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
4841 cinfo->vcenter = 1;
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
4842 else
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
4843 {
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
4844 cinfo = calloc(1, sizeof(ColorInfo));
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
4845 cinfo->fore = cinfo->back = -1;
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
4846 cinfo->vcenter = 1;
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
4847
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
4848 cinfo->pOldProc = SubclassWindow(handle, _colorwndproc);
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
4849 SetWindowLong(handle, GWL_USERDATA, (ULONG)cinfo);
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
4850 }
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
4851 }
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
4852 else if(cinfo)
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
4853 cinfo->vcenter = 0;
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
4854
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4855 SetWindowLong(handle, GWL_STYLE, tmp);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4856 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4857
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4858 /* Finds the physical ID from the reference ID */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4859 int _findnotebookid(NotebookPage **array, int pageid)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4860 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4861 int z;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4862
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4863 for(z=0;z<256;z++)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4864 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4865 if(array[z] && array[z]->realid == pageid)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4866 return z;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4867 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4868 return -1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4869 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4870
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4871 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4872 * Adds a new page to specified notebook.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4873 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4874 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4875 * flags: Any additional page creation flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4876 * front: If TRUE page is added at the beginning.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4877 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4878 unsigned long API dw_notebook_page_new(HWND handle, ULONG flags, int front)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4879 {
191
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
4880 NotebookPage **array = (NotebookPage **)dw_window_get_data(handle, "_dw_array");
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4881
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4882 if(array)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4883 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4884 int z, refid = -1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4885
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4886 for(z=0;z<256;z++)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4887 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4888 if(_findnotebookid(array, z) == -1)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4889 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4890 refid = z;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4891 break;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4892 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4893 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4894
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4895 if(refid == -1)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4896 return -1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4897
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4898 for(z=0;z<256;z++)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4899 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4900 if(!array[z])
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4901 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4902 int oldpage = TabCtrl_GetCurSel(handle);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4903
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4904 array[z] = calloc(1, sizeof(NotebookPage));
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4905 array[z]->realid = refid;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4906 array[z]->item.mask = TCIF_TEXT;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4907 array[z]->item.iImage = -1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4908 array[z]->item.pszText = "";
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4909 TabCtrl_InsertItem(handle, z, &(array[z]->item));
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4910
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4911 if(oldpage > -1 && array[oldpage])
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4912 SetParent(array[oldpage]->hwnd, DW_HWND_OBJECT);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4913
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4914 TabCtrl_SetCurSel(handle, z);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4915 return refid;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4916 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4917 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4918 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4919 return -1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4920 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4921
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4922 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4923 * Sets the text on the specified notebook tab.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4924 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4925 * handle: Notebook handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4926 * pageid: Page ID of the tab to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4927 * text: Pointer to the text to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4928 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4929 void API dw_notebook_page_set_text(HWND handle, ULONG pageidx, char *text)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4930 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4931
191
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
4932 NotebookPage **array = (NotebookPage **)dw_window_get_data(handle, "_dw_array");
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4933 int pageid;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4934
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4935 if(!array)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4936 return;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4937
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4938 pageid = _findnotebookid(array, pageidx);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4939
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4940 if(pageid > -1 && array[pageid])
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4941 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4942 array[pageid]->item.mask = TCIF_TEXT;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4943 array[pageid]->item.pszText = text;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4944 TabCtrl_SetItem(handle, pageid, &(array[pageid]->item));
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4945 _resize_notebook_page(handle, pageid);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4946 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4947 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4948
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4949 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4950 * Sets the text on the specified notebook tab status area.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4951 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4952 * handle: Notebook handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4953 * pageid: Page ID of the tab to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4954 * text: Pointer to the text to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4955 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4956 void API dw_notebook_page_set_status_text(HWND handle, ULONG pageid, char *text)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4957 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4958 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4959
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4960 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4961 * Packs the specified box into the notebook page.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4962 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4963 * handle: Handle to the notebook to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4964 * pageid: Page ID in the notebook which is being packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4965 * page: Box handle to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4966 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4967 void API dw_notebook_pack(HWND handle, ULONG pageidx, HWND page)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4968 {
191
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
4969 NotebookPage **array = (NotebookPage **)dw_window_get_data(handle, "_dw_array");
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4970 int pageid;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4971
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4972 if(!array)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4973 return;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4974
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4975 pageid = _findnotebookid(array, pageidx);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4976
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4977 if(pageid > -1 && array[pageid])
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4978 {
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
4979 HWND tmpbox = dw_box_new(DW_VERT, 0);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4980
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4981 dw_box_pack_start(tmpbox, page, 0, 0, TRUE, TRUE, 0);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4982 SubclassWindow(tmpbox, _wndproc);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4983 if(array[pageid]->hwnd)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4984 dw_window_destroy(array[pageid]->hwnd);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4985 array[pageid]->hwnd = tmpbox;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4986 if(pageidx == dw_notebook_page_query(handle))
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4987 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4988 SetParent(tmpbox, handle);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4989 _resize_notebook_page(handle, pageid);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4990 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4991 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4992 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4993
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4994 /*
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4995 * Remove a page from a notebook.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4996 * Parameters:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4997 * handle: Handle to the notebook widget.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4998 * pageid: ID of the page to be destroyed.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4999 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5000 void API dw_notebook_page_destroy(HWND handle, unsigned int pageidx)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5001 {
191
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
5002 NotebookPage **array = (NotebookPage **)dw_window_get_data(handle, "_dw_array");
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5003 int newid = -1, z, pageid;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5004
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5005 if(!array)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5006 return;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5007
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5008 pageid = _findnotebookid(array, pageidx);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5009
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5010 if(pageid < 0)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5011 return;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5012
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5013 if(array[pageid])
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5014 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5015 SetParent(array[pageid]->hwnd, DW_HWND_OBJECT);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5016 free(array[pageid]);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5017 array[pageid] = NULL;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5018 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5019
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5020 TabCtrl_DeleteItem(handle, pageid);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5021
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5022 /* Shift the pages over 1 */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5023 for(z=pageid;z<255;z++)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5024 array[z] = array[z+1];
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5025 array[255] = NULL;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5026
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5027 for(z=0;z<256;z++)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5028 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5029 if(array[z])
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5030 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5031 newid = z;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5032 break;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5033 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5034 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5035 if(newid > -1)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5036 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5037 SetParent(array[newid]->hwnd, handle);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5038 _resize_notebook_page(handle, newid);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5039 dw_notebook_page_set(handle, array[newid]->realid);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5040 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5041 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5042
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5043 /*
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5044 * Queries the currently visible page ID.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5045 * Parameters:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5046 * handle: Handle to the notebook widget.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5047 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5048 unsigned int API dw_notebook_page_query(HWND handle)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5049 {
191
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
5050 NotebookPage **array = (NotebookPage **)dw_window_get_data(handle, "_dw_array");
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5051 int physid = TabCtrl_GetCurSel(handle);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5052
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5053 if(physid > -1 && physid < 256 && array && array[physid])
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5054 return array[physid]->realid;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5055 return -1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5056 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5057
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5058 /*
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5059 * Sets the currently visible page ID.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5060 * Parameters:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5061 * handle: Handle to the notebook widget.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5062 * pageid: ID of the page to be made visible.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5063 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5064 void API dw_notebook_page_set(HWND handle, unsigned int pageidx)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5065 {
191
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
5066 NotebookPage **array = (NotebookPage **)dw_window_get_data(handle, "_dw_array");
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5067 int pageid;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5068
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5069 if(!array)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5070 return;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5071
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5072 pageid = _findnotebookid(array, pageidx);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5073
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5074 if(pageid > -1 && pageid < 256)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5075 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5076 int oldpage = TabCtrl_GetCurSel(handle);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5077
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5078 if(oldpage > -1 && array && array[oldpage])
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5079 SetParent(array[oldpage]->hwnd, DW_HWND_OBJECT);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5080
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5081 TabCtrl_SetCurSel(handle, pageid);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5082
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5083 SetParent(array[pageid]->hwnd, handle);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5084 _resize_notebook_page(handle, pageid);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5085 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5086 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5087
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5088 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5089 * Appends the specified text to the listbox's (or combobox) entry list.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5090 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5091 * handle: Handle to the listbox to be appended to.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5092 * text: Text to append into listbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5093 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5094 void API dw_listbox_append(HWND handle, char *text)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5095 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5096 char tmpbuf[100];
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5097
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5098 GetClassName(handle, tmpbuf, 99);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5099
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5100 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME))==0)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5101 SendMessage(handle,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5102 CB_ADDSTRING,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5103 0, (LPARAM)text);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5104 else
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5105 SendMessage(handle,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5106 LB_ADDSTRING,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5107 0, (LPARAM)text);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5108 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5109
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5110 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5111 * Clears the listbox's (or combobox) list of all entries.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5112 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5113 * handle: Handle to the listbox to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5114 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5115 void API dw_listbox_clear(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5116 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5117 char tmpbuf[100];
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5118
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5119 GetClassName(handle, tmpbuf, 99);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5120
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5121 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME))==0)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5122 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5123 char *buf = dw_window_get_text(handle);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5124
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5125 SendMessage(handle,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5126 CB_RESETCONTENT, 0L, 0L);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5127
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5128 if(buf)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5129 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5130 dw_window_set_text(handle, buf);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5131 free(buf);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5132 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5133 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5134 else
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5135 SendMessage(handle,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5136 LB_RESETCONTENT, 0L, 0L);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5137 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5138
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5139 /*
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5140 * Sets the text of a given listbox entry.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5141 * Parameters:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5142 * handle: Handle to the listbox to be queried.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5143 * index: Index into the list to be queried.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5144 * buffer: Buffer where text will be copied.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5145 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5146 void API dw_listbox_set_text(HWND handle, unsigned int index, char *buffer)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5147 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5148 unsigned int sel = (unsigned int)SendMessage(handle, LB_GETCURSEL, 0, 0);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5149 SendMessage(handle, LB_DELETESTRING, (WPARAM)index, 0);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5150 SendMessage(handle, LB_INSERTSTRING, (WPARAM)index, (LPARAM)buffer);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5151 SendMessage(handle, LB_SETCURSEL, (WPARAM)sel, 0);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5152 SendMessage(handle, LB_SETSEL, (WPARAM)TRUE, (LPARAM)sel);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5153 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5154
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5155 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5156 * Copies the given index item's text into buffer.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5157 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5158 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5159 * index: Index into the list to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5160 * buffer: Buffer where text will be copied.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5161 * length: Length of the buffer (including NULL).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5162 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5163 void API dw_listbox_query_text(HWND handle, unsigned int index, char *buffer, unsigned int length)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5164 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5165 SendMessage(handle,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5166 LB_GETTEXT, (WPARAM)index, (LPARAM)buffer);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5167 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5168
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5169 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5170 * Returns the index to the item in the list currently selected.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5171 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5172 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5173 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5174 unsigned int API dw_listbox_selected(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5175 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5176 char tmpbuf[100];
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5177
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5178 GetClassName(handle, tmpbuf, 99);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5179
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5180 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME))==0)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5181 return (unsigned int)SendMessage(handle,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5182 CB_GETCURSEL,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5183 0, 0);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5184
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5185 return (unsigned int)SendMessage(handle,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5186 LB_GETCURSEL,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5187 0, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5188 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5189
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5190 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5191 * Returns the index to the current selected item or -1 when done.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5192 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5193 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5194 * where: Either the previous return or -1 to restart.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5195 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5196 int API dw_listbox_selected_multi(HWND handle, int where)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5197 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5198 int *array, count, z;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5199
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5200 count = (int)SendMessage(handle, LB_GETSELCOUNT, 0, 0);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5201 if(count > 0)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5202 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5203 array = malloc(sizeof(int)*count);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5204 SendMessage(handle, LB_GETSELITEMS, (WPARAM)count, (LPARAM)array);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5205
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5206 if(where == -1)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5207 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5208 int ret = array[0];
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5209 free(array);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5210 return ret;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5211 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5212 for(z=0;z<count;z++)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5213 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5214 if(array[z] == where && (z+1) < count)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5215 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5216 int ret = array[z+1];
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5217 free(array);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5218 return ret;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5219 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5220 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5221 free(array);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5222 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5223 return -1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5224 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5225
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5226 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5227 * Sets the selection state of a given index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5228 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5229 * handle: Handle to the listbox to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5230 * index: Item index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5231 * state: TRUE if selected FALSE if unselected.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5232 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5233 void API dw_listbox_select(HWND handle, int index, int state)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5234 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5235 char tmpbuf[100];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5236
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5237 GetClassName(handle, tmpbuf, 99);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5238
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5239 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME))==0)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5240 SendMessage(handle, CB_SETCURSEL, (WPARAM)index, 0);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5241 else
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5242 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5243 SendMessage(handle, LB_SETCURSEL, (WPARAM)index, 0);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5244 SendMessage(handle, LB_SETSEL, (WPARAM)state, (LPARAM)index);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5245 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5246 _wndproc(handle, WM_COMMAND, (WPARAM)(LBN_SELCHANGE << 16), (LPARAM)handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5247 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5248
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5249 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5250 * Deletes the item with given index from the list.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5251 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5252 * handle: Handle to the listbox to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5253 * index: Item index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5254 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5255 void API dw_listbox_delete(HWND handle, int index)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5256 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5257 SendMessage(handle, LB_DELETESTRING, (WPARAM)index, 0);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5258 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5259
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5260 /*
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5261 * Returns the listbox's item count.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5262 * Parameters:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5263 * handle: Handle to the listbox to be cleared.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5264 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5265 int API dw_listbox_count(HWND handle)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5266 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5267 char tmpbuf[100];
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5268
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5269 GetClassName(handle, tmpbuf, 99);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5270
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5271 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME))==0)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5272 return (int)SendMessage(handle,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5273 CB_GETCOUNT,0L, 0L);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5274
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5275 return (int)SendMessage(handle,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5276 LB_GETCOUNT,0L, 0L);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5277 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5278
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5279 /*
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5280 * Sets the topmost item in the viewport.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5281 * Parameters:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5282 * handle: Handle to the listbox to be cleared.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5283 * top: Index to the top item.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5284 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5285 void API dw_listbox_set_top(HWND handle, int top)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5286 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5287 SendMessage(handle, LB_SETTOPINDEX, (WPARAM)top, 0);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5288 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5289
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5290 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5291 * Adds text to an MLE box and returns the current point.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5292 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5293 * handle: Handle to the MLE to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5294 * buffer: Text buffer to be imported.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5295 * startpoint: Point to start entering text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5296 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5297 unsigned int API dw_mle_import(HWND handle, char *buffer, int startpoint)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5298 {
95
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5299 int textlen, len = GetWindowTextLength(handle);
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5300 char *tmpbuf;
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5301
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5302 if((textlen = strlen(buffer)) < 1)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5303 return startpoint;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5304
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5305 startpoint++;
95
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5306 tmpbuf = calloc(1, len + textlen + startpoint + 2);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5307
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5308 if(startpoint < 0)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5309 startpoint = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5310
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5311 if(len)
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5312 {
95
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5313 char *dest, *start;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5314 int copylen = len - startpoint;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5315
95
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5316 GetWindowText(handle, tmpbuf, len+1);
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5317
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5318 dest = &tmpbuf[startpoint+textlen-1];
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5319 start = &tmpbuf[startpoint];
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5320
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5321 if(copylen > 0)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5322 memcpy(dest, start, copylen);
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5323 }
95
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5324 memcpy(&tmpbuf[startpoint], buffer, textlen);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5325
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5326 SetWindowText(handle, tmpbuf);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5327
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5328 free(tmpbuf);
95
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5329 return (startpoint + textlen - 1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5330 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5331
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5332 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5333 * Grabs text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5334 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5335 * handle: Handle to the MLE to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5336 * buffer: Text buffer to be exported.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5337 * startpoint: Point to start grabbing text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5338 * length: Amount of text to be grabbed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5339 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5340 void API dw_mle_export(HWND handle, char *buffer, int startpoint, int length)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5341 {
95
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5342 int max, len = GetWindowTextLength(handle);
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5343 char *tmpbuf = calloc(1, len+2);
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5344
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5345 if(len)
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5346 GetWindowText(handle, tmpbuf, len+1);
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5347
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5348 buffer[0] = 0;
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5349
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5350 if(startpoint < len)
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5351 {
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5352 max = MIN(length, len - startpoint);
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5353
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5354 memcpy(buffer, &tmpbuf[startpoint], max);
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5355 }
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5356
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5357 free(tmpbuf);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5358 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5359
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5360 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5361 * Obtains information about an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5362 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5363 * handle: Handle to the MLE to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5364 * bytes: A pointer to a variable to return the total bytes.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5365 * lines: A pointer to a variable to return the number of lines.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5366 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5367 void API dw_mle_query(HWND handle, unsigned long *bytes, unsigned long *lines)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5368 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5369 if(bytes)
95
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5370 *bytes = GetWindowTextLength(handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5371 if(lines)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5372 *lines = (unsigned long)SendMessage(handle, EM_GETLINECOUNT, 0, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5373 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5374
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5375 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5376 * Deletes text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5377 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5378 * handle: Handle to the MLE to be deleted from.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5379 * startpoint: Point to start deleting text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5380 * length: Amount of text to be deleted.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5381 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5382 void API dw_mle_delete(HWND handle, int startpoint, int length)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5383 {
95
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5384 int len = GetWindowTextLength(handle);
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5385 char *tmpbuf = calloc(1, len+2);
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5386
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5387 GetWindowText(handle, tmpbuf, len+1);
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5388
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5389 if(startpoint + length < len)
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5390 {
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5391 strcpy(&tmpbuf[startpoint], &tmpbuf[startpoint+length]);
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5392
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5393 SetWindowText(handle, tmpbuf);
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5394 }
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5395
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5396 free(tmpbuf);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5397 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5398
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5399 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5400 * Clears all text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5401 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5402 * handle: Handle to the MLE to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5403 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5404 void API dw_mle_clear(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5405 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5406 SetWindowText(handle, "");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5407 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5408
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5409 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5410 * Sets the visible line of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5411 * Parameters:
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5412 * handle: Handle to the MLE.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5413 * line: Line to be visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5414 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5415 void API dw_mle_set_visible(HWND handle, int line)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5416 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5417 int point = (int)SendMessage(handle, EM_LINEINDEX, (WPARAM)line, 0);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5418 dw_mle_set(handle, point);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5419 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5420
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5421 /*
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5422 * Sets the editablity of an MLE box.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5423 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5424 * handle: Handle to the MLE.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5425 * state: TRUE if it can be edited, FALSE for readonly.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5426 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5427 void API dw_mle_set_editable(HWND handle, int state)
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5428 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5429 SendMessage(handle, EM_SETREADONLY, (WPARAM)(state ? FALSE : TRUE), 0);
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5430 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5431
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5432 /*
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5433 * Sets the word wrap state of an MLE box.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5434 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5435 * handle: Handle to the MLE.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5436 * state: TRUE if it wraps, FALSE if it doesn't.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5437 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5438 void API dw_mle_set_word_wrap(HWND handle, int state)
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5439 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5440 /* If ES_AUTOHSCROLL is not set and there is not
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5441 * horizontal scrollbar it word wraps.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5442 */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5443 if(state)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5444 dw_window_set_style(handle, 0, ES_AUTOHSCROLL);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5445 else
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5446 dw_window_set_style(handle, ES_AUTOHSCROLL, ES_AUTOHSCROLL);
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5447 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5448
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5449 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5450 * Sets the current cursor position of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5451 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5452 * handle: Handle to the MLE to be positioned.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5453 * point: Point to position cursor.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5454 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5455 void API dw_mle_set(HWND handle, int point)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5456 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5457 SendMessage(handle, EM_SETSEL, (WPARAM)point, (LPARAM)point);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5458 SendMessage(handle, EM_SCROLLCARET, 0, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5459 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5460
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5461 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5462 * Finds text in an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5463 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5464 * handle: Handle to the MLE to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5465 * text: Text to search for.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5466 * point: Start point of search.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5467 * flags: Search specific flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5468 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5469 int API dw_mle_search(HWND handle, char *text, int point, unsigned long flags)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5470 {
95
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5471 int len = GetWindowTextLength(handle);
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5472 char *tmpbuf = calloc(1, len+2);
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5473 int z, textlen, retval = 0;
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5474
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5475 GetWindowText(handle, tmpbuf, len+1);
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
5476
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5477 textlen = strlen(text);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5478
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5479 if(flags & DW_MLE_CASESENSITIVE)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5480 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5481 for(z=point;z<(len-textlen) && !retval;z++)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5482 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5483 if(strncmp(&tmpbuf[z], text, textlen) == 0)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5484 retval = z + textlen;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5485 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5486 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5487 else
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5488 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5489 for(z=point;z<(len-textlen) && !retval;z++)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5490 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5491 if(strnicmp(&tmpbuf[z], text, textlen) == 0)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5492 retval = z + textlen;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5493 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5494 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5495
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5496 if(retval)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5497 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5498 SendMessage(handle, EM_SETSEL, (WPARAM)retval - textlen, (LPARAM)retval);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5499 SendMessage(handle, EM_SCROLLCARET, 0, 0);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5500 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5501
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5502 free(tmpbuf);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5503
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5504 return retval;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5505 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5506
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5507 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5508 * Stops redrawing of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5509 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5510 * handle: Handle to the MLE to freeze.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5511 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5512 void API dw_mle_freeze(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5513 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5514 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5515
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5516 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5517 * Resumes redrawing of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5518 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5519 * handle: Handle to the MLE to thaw.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5520 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5521 void API dw_mle_thaw(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5522 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5523 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5524
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5525 /*
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 32
diff changeset
5526 * Returns the range of the percent bar.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5527 * Parameters:
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5528 * handle: Handle to the percent bar to be queried.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5529 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5530 unsigned int API dw_percent_query_range(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5531 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5532 return (unsigned int)SendMessage(handle, PBM_GETRANGE, (WPARAM)FALSE, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5533 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5534
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5535 /*
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 32
diff changeset
5536 * Sets the percent bar position.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5537 * Parameters:
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5538 * handle: Handle to the percent bar to be set.
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5539 * position: Position of the percent bar withing the range.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5540 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5541 void API dw_percent_set_pos(HWND handle, unsigned int position)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5542 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5543 SendMessage(handle, PBM_SETPOS, (WPARAM)position, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5544 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5545
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5546 /*
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5547 * Returns the position of the slider.
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5548 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5549 * handle: Handle to the slider to be queried.
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5550 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5551 unsigned int API dw_slider_query_pos(HWND handle)
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5552 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5553 int max = (int)SendMessage(handle, TBM_GETRANGEMAX, 0, 0);
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5554 ULONG currentstyle = GetWindowLong(handle, GWL_STYLE);
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5555
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5556 if(currentstyle & TBS_VERT)
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5557 return max - (unsigned int)SendMessage(handle, TBM_GETPOS, 0, 0);
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5558 return (unsigned int)SendMessage(handle, TBM_GETPOS, 0, 0);
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5559 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5560
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5561 /*
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5562 * Sets the slider position.
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5563 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5564 * handle: Handle to the slider to be set.
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5565 * position: Position of the slider withing the range.
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5566 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5567 void API dw_slider_set_pos(HWND handle, unsigned int position)
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5568 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5569 int max = (int)SendMessage(handle, TBM_GETRANGEMAX, 0, 0);
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5570 ULONG currentstyle = GetWindowLong(handle, GWL_STYLE);
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5571
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5572 if(currentstyle & TBS_VERT)
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5573 SendMessage(handle, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)max - position);
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5574 else
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5575 SendMessage(handle, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)position);
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5576 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5577
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5578 /*
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
5579 * Returns the position of the scrollbar.
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
5580 * Parameters:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
5581 * handle: Handle to the scrollbar to be queried.
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
5582 */
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
5583 unsigned int API dw_scrollbar_query_pos(HWND handle)
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
5584 {
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
5585 return (unsigned int)SendMessage(handle, SBM_GETPOS, 0, 0);
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
5586 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
5587
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
5588 /*
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
5589 * Sets the scrollbar position.
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
5590 * Parameters:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
5591 * handle: Handle to the scrollbar to be set.
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
5592 * position: Position of the scrollbar withing the range.
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
5593 */
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
5594 void API dw_scrollbar_set_pos(HWND handle, unsigned int position)
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
5595 {
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
5596 dw_window_set_data(handle, "_dw_scrollbar_value", (void *)position);
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
5597 SendMessage(handle, SBM_SETPOS, (WPARAM)position, (LPARAM)TRUE);
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
5598 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
5599
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
5600 /*
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
5601 * Sets the scrollbar range.
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
5602 * Parameters:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
5603 * handle: Handle to the scrollbar to be set.
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
5604 * range: Maximum range value.
204
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
5605 * visible: Visible area relative to the range.
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
5606 */
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
5607 void API dw_scrollbar_set_range(HWND handle, unsigned int range, unsigned int visible)
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
5608 {
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
5609 SCROLLINFO si;
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
5610
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
5611 si.cbSize = sizeof(SCROLLINFO);
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
5612 si.fMask = SIF_RANGE | SIF_PAGE;
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
5613 si.nMin = 0;
209
85f25e8c1b1e nMax is inclusive or exclusive?
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 204
diff changeset
5614 si.nMax = range - 1;
204
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
5615 si.nPage = visible;
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
5616 SendMessage(handle, SBM_SETSCROLLINFO, (WPARAM)TRUE, (LPARAM)&si);
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
5617 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
5618
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
5619 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5620 * Sets the spinbutton value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5621 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5622 * handle: Handle to the spinbutton to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5623 * position: Current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5624 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5625 void API dw_spinbutton_set_pos(HWND handle, long position)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5626 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5627 char tmpbuf[100];
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5628 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5629
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5630 sprintf(tmpbuf, "%d", position);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5631
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5632 if(cinfo && cinfo->buddy)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5633 SetWindowText(cinfo->buddy, tmpbuf);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5634
75
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
5635 if(IS_IE5PLUS)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5636 SendMessage(handle, UDM_SETPOS32, 0, (LPARAM)position);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5637 else
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5638 SendMessage(handle, UDM_SETPOS, 0, (LPARAM)MAKELONG((short)position, 0));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5639 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5640
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5641 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5642 * Sets the spinbutton limits.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5643 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5644 * handle: Handle to the spinbutton to be set.
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5645 * position: Current value of the spinbutton.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5646 * position: Current value of the spinbutton.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5647 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5648 void API dw_spinbutton_set_limits(HWND handle, long upper, long lower)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5649 {
75
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
5650 if(IS_IE5PLUS)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5651 SendMessage(handle, UDM_SETRANGE32, (WPARAM)lower,(LPARAM)upper);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5652 else
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5653 SendMessage(handle, UDM_SETRANGE32, (WPARAM)((short)lower),
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5654 (LPARAM)((short)upper));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5655 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5656
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5657 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5658 * Sets the entryfield character limit.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5659 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5660 * handle: Handle to the spinbutton to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5661 * limit: Number of characters the entryfield will take.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5662 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5663 void API dw_entryfield_set_limit(HWND handle, ULONG limit)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5664 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5665 SendMessage(handle, EM_SETLIMITTEXT, (WPARAM)limit, 0);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5666 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5667
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5668 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5669 * Returns the current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5670 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5671 * handle: Handle to the spinbutton to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5672 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5673 long API dw_spinbutton_query(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5674 {
75
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
5675 if(IS_IE5PLUS)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5676 return (long)SendMessage(handle, UDM_GETPOS32, 0, 0);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5677 else
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5678 return (long)SendMessage(handle, UDM_GETPOS, 0, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5679 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5680
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5681 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5682 * Returns the state of the checkbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5683 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5684 * handle: Handle to the checkbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5685 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5686 int API dw_checkbox_query(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5687 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5688 if(SendMessage(handle, BM_GETCHECK, 0, 0) == BST_CHECKED)
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5689 return (in_checkbox_handler ? FALSE : TRUE);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5690 return (in_checkbox_handler ? TRUE : FALSE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5691 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5692
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5693 /* This function unchecks all radiobuttons on a box */
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5694 BOOL CALLBACK _uncheck_radios(HWND handle, LPARAM lParam)
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5695 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5696 char tmpbuf[100];
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5697
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5698 GetClassName(handle, tmpbuf, 99);
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5699
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5700 if(strnicmp(tmpbuf, BUTTONCLASSNAME, strlen(BUTTONCLASSNAME)+1)==0)
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5701 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5702 BubbleButton *bubble= (BubbleButton *)GetWindowLong(handle, GWL_USERDATA);
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5703
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5704 if(bubble && !bubble->checkbox)
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5705 SendMessage(handle, BM_SETCHECK, 0, 0);
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5706 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5707 return TRUE;
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5708 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5709 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5710 * Sets the state of the checkbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5711 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5712 * handle: Handle to the checkbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5713 * value: TRUE for checked, FALSE for unchecked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5714 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5715 void API dw_checkbox_set(HWND handle, int value)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5716 {
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5717 BubbleButton *bubble= (BubbleButton *)GetWindowLong(handle, GWL_USERDATA);
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5718
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5719 if(bubble && !bubble->checkbox)
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5720 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5721 HWND parent = GetParent(handle);
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5722
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5723 if(parent)
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5724 EnumChildWindows(parent, _uncheck_radios, 0);
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
5725 }
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5726 SendMessage(handle, BM_SETCHECK, (WPARAM)value, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5727 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5728
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5729 /*
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5730 * Inserts an item into a tree window (widget) after another item.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5731 * Parameters:
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5732 * handle: Handle to the tree to be inserted.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5733 * item: Handle to the item to be positioned after.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5734 * title: The text title of the entry.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5735 * icon: Handle to coresponding icon.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5736 * parent: Parent handle or 0 if root.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5737 * itemdata: Item specific data.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5738 */
328
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 321
diff changeset
5739 HTREEITEM API dw_tree_insert_after(HWND handle, HTREEITEM item, char *title, unsigned long icon, HTREEITEM parent, void *itemdata)
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5740 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5741 TVITEM tvi;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5742 TVINSERTSTRUCT tvins;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5743 HTREEITEM hti;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5744 void **ptrs= malloc(sizeof(void *) * 2);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5745
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5746 ptrs[0] = title;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5747 ptrs[1] = itemdata;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5748
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5749 tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5750 tvi.pszText = title;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5751 tvi.lParam = (LONG)ptrs;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5752 tvi.cchTextMax = strlen(title);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5753 tvi.iSelectedImage = tvi.iImage = _lookup_icon(handle, (HICON)icon, 1);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5754
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5755 tvins.item = tvi;
328
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 321
diff changeset
5756 tvins.hParent = parent;
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 321
diff changeset
5757 tvins.hInsertAfter = item ? item : TVI_FIRST;
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5758
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5759 hti = TreeView_InsertItem(handle, &tvins);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5760
328
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 321
diff changeset
5761 return hti;
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5762 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5763
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5764 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5765 * Inserts an item into a tree window (widget).
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5766 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5767 * handle: Handle to the tree to be inserted.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5768 * title: The text title of the entry.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5769 * icon: Handle to coresponding icon.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5770 * parent: Parent handle or 0 if root.
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5771 * itemdata: Item specific data.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5772 */
328
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 321
diff changeset
5773 HTREEITEM API dw_tree_insert(HWND handle, char *title, unsigned long icon, HTREEITEM parent, void *itemdata)
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5774 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5775 TVITEM tvi;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5776 TVINSERTSTRUCT tvins;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5777 HTREEITEM hti;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5778 void **ptrs= malloc(sizeof(void *) * 2);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5779
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5780 ptrs[0] = title;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5781 ptrs[1] = itemdata;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5782
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5783 tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5784 tvi.pszText = title;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5785 tvi.lParam = (LONG)ptrs;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5786 tvi.cchTextMax = strlen(title);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5787 tvi.iSelectedImage = tvi.iImage = _lookup_icon(handle, (HICON)icon, 1);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5788
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5789 tvins.item = tvi;
328
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 321
diff changeset
5790 tvins.hParent = parent;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5791 tvins.hInsertAfter = TVI_LAST;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5792
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5793 hti = TreeView_InsertItem(handle, &tvins);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5794
328
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 321
diff changeset
5795 return hti;
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5796 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5797
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5798 /*
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5799 * Sets the text and icon of an item in a tree window (widget).
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5800 * Parameters:
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5801 * handle: Handle to the tree containing the item.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5802 * item: Handle of the item to be modified.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5803 * title: The text title of the entry.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5804 * icon: Handle to coresponding icon.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5805 */
328
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 321
diff changeset
5806 void API dw_tree_set(HWND handle, HTREEITEM item, char *title, unsigned long icon)
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5807 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5808 TVITEM tvi;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5809 void **ptrs;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5810
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5811 tvi.mask = TVIF_HANDLE;
328
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 321
diff changeset
5812 tvi.hItem = item;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5813
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5814 if(TreeView_GetItem(handle, &tvi))
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5815 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5816
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5817 ptrs = (void **)tvi.lParam;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5818 ptrs[0] = title;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5819
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5820 tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5821 tvi.pszText = title;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5822 tvi.cchTextMax = strlen(title);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5823 tvi.iSelectedImage = tvi.iImage = _lookup_icon(handle, (HICON)icon, 1);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5824 tvi.hItem = (HTREEITEM)item;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5825
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5826 TreeView_SetItem(handle, &tvi);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5827 }
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5828 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5829
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5830 /*
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5831 * Sets the item data of a tree item.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5832 * Parameters:
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5833 * handle: Handle to the tree containing the item.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5834 * item: Handle of the item to be modified.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5835 * itemdata: User defined data to be associated with item.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5836 */
328
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 321
diff changeset
5837 void API dw_tree_set_data(HWND handle, HTREEITEM item, void *itemdata)
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5838 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5839 TVITEM tvi;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5840 void **ptrs;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5841
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5842 tvi.mask = TVIF_HANDLE;
328
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 321
diff changeset
5843 tvi.hItem = item;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5844
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5845 if(TreeView_GetItem(handle, &tvi))
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5846 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5847 ptrs = (void **)tvi.lParam;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5848 ptrs[1] = itemdata;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5849 }
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5850 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5851
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5852 /*
317
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
5853 * Gets the item data of a tree item.
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
5854 * Parameters:
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
5855 * handle: Handle to the tree containing the item.
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
5856 * item: Handle of the item to be modified.
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
5857 */
328
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 321
diff changeset
5858 void * API dw_tree_get_data(HWND handle, HTREEITEM item)
317
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
5859 {
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
5860 TVITEM tvi;
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
5861 void **ptrs;
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
5862
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
5863 tvi.mask = TVIF_HANDLE;
328
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 321
diff changeset
5864 tvi.hItem = item;
317
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
5865
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
5866 if(TreeView_GetItem(handle, &tvi))
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
5867 {
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
5868 ptrs = (void **)tvi.lParam;
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
5869 return ptrs[1];
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
5870 }
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
5871 return NULL;
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
5872 }
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
5873
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
5874 /*
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5875 * Sets this item as the active selection.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5876 * Parameters:
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5877 * handle: Handle to the tree window (widget) to be selected.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5878 * item: Handle to the item to be selected.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5879 */
328
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 321
diff changeset
5880 void API dw_tree_item_select(HWND handle, HTREEITEM item)
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5881 {
321
be76b984620a Make sure dw_tree_item_select() does not cause a DW_SIGNAL_ITEM_SELECT.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 318
diff changeset
5882 dw_window_set_data(handle, "_dw_select_item", (void *)1);
328
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 321
diff changeset
5883 TreeView_SelectItem(handle, item);
321
be76b984620a Make sure dw_tree_item_select() does not cause a DW_SIGNAL_ITEM_SELECT.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 318
diff changeset
5884 dw_window_set_data(handle, "_dw_select_item", (void *)0);
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5885 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5886
291
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
5887 /* Delete all tree subitems */
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
5888 void _dw_tree_delete_recursive(HWND handle, HTREEITEM node)
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
5889 {
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
5890 HTREEITEM hti;
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
5891
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
5892 hti = TreeView_GetChild(handle, node);
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
5893
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
5894 while(hti)
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
5895 {
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
5896 HTREEITEM lastitem = hti;
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
5897
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
5898 hti = TreeView_GetNextSibling(handle, hti);
328
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 321
diff changeset
5899 dw_tree_delete(handle, lastitem);
291
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
5900 }
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
5901 }
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
5902
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5903 /*
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5904 * Removes all nodes from a tree.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5905 * Parameters:
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5906 * handle: Handle to the window (widget) to be cleared.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5907 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5908 void API dw_tree_clear(HWND handle)
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5909 {
291
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
5910 HTREEITEM hti = TreeView_GetRoot(handle);
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
5911
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
5912 while(hti)
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
5913 {
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
5914 HTREEITEM lastitem = hti;
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
5915
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
5916 _dw_tree_delete_recursive(handle, hti);
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
5917 hti = TreeView_GetNextSibling(handle, hti);
328
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 321
diff changeset
5918 dw_tree_delete(handle, lastitem);
291
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
5919 }
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5920 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5921
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5922 /*
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5923 * Expands a node on a tree.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5924 * Parameters:
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5925 * handle: Handle to the tree window (widget).
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5926 * item: Handle to node to be expanded.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5927 */
328
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 321
diff changeset
5928 void API dw_tree_expand(HWND handle, HTREEITEM item)
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 321
diff changeset
5929 {
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 321
diff changeset
5930 TreeView_Expand(handle, item, TVE_EXPAND);
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5931 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5932
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5933 /*
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5934 * Collapses a node on a tree.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5935 * Parameters:
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5936 * handle: Handle to the tree window (widget).
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5937 * item: Handle to node to be collapsed.
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5938 */
328
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 321
diff changeset
5939 void API dw_tree_collapse(HWND handle, HTREEITEM item)
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 321
diff changeset
5940 {
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 321
diff changeset
5941 TreeView_Expand(handle, item, TVE_COLLAPSE);
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5942 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5943
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5944 /*
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5945 * Removes a node from a tree.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5946 * Parameters:
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5947 * handle: Handle to the window (widget) to be cleared.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5948 * item: Handle to node to be deleted.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5949 */
328
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 321
diff changeset
5950 void API dw_tree_delete(HWND handle, HTREEITEM item)
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5951 {
291
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
5952 TVITEM tvi;
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
5953 void **ptrs;
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
5954
328
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 321
diff changeset
5955 if(item == TVI_ROOT || !item)
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5956 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
5957
291
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
5958 tvi.mask = TVIF_HANDLE;
328
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 321
diff changeset
5959 tvi.hItem = item;
291
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
5960
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
5961 if(TreeView_GetItem(handle, &tvi))
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
5962 ptrs = (void **)tvi.lParam;
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
5963
328
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 321
diff changeset
5964 _dw_tree_delete_recursive(handle, item);
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 321
diff changeset
5965 TreeView_DeleteItem(handle, item);
291
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
5966 if(ptrs)
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
5967 free(ptrs);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5968 }
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5969
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5970 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5971 * Sets up the container columns.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5972 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5973 * handle: Handle to the container to be configured.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5974 * flags: An array of unsigned longs with column flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5975 * titles: An array of strings with column text titles.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5976 * count: The number of columns (this should match the arrays).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5977 * separator: The column number that contains the main separator.
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5978 * (only used on OS/2 but must be >= 0 on all)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5979 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5980 int API dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5981 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5982 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLong(handle, GWL_USERDATA);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5983 int z, l = 0;
105
ad95fc623ff3 Some changes to the container optimization code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 104
diff changeset
5984 unsigned long *tempflags = calloc(sizeof(unsigned long), count + 2);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5985 LV_COLUMN lvc;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5986
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5987 if(separator == -1)
105
ad95fc623ff3 Some changes to the container optimization code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 104
diff changeset
5988 {
ad95fc623ff3 Some changes to the container optimization code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 104
diff changeset
5989 tempflags[0] = DW_CFA_RESERVED;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5990 l = 1;
105
ad95fc623ff3 Some changes to the container optimization code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 104
diff changeset
5991 }
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5992
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5993 memcpy(&tempflags[l], flags, sizeof(unsigned long) * count);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5994 tempflags[count + l] = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5995 cinfo->flags = tempflags;
71
291c30a92b9b Fixed a bug where if dw_filesystem_* was used then the last column
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
5996 cinfo->columns = count + l;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5997
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5998
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5999 for(z=0;z<count;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6000 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6001 if(titles[z])
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6002 {
102
372a7581b312 Minor changes to the container code on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 95
diff changeset
6003 lvc.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6004 lvc.pszText = titles[z];
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6005 lvc.cchTextMax = strlen(titles[z]);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6006 lvc.fmt = flags[z];
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6007 lvc.cx = 75;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6008 lvc.iSubItem = count;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6009 SendMessage(handle, LVM_INSERTCOLUMN, (WPARAM)z + l, (LPARAM)&lvc);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6010 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6011 }
168
627e531ca530 Allow subitems to have icons so the container controls will be the same
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
6012 ListView_SetExtendedListViewStyle(handle, LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6013 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6014 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6015
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6016 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6017 * Sets up the filesystem columns, note: filesystem always has an icon/filename field.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6018 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6019 * handle: Handle to the container to be configured.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6020 * flags: An array of unsigned longs with column flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6021 * titles: An array of strings with column text titles.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6022 * count: The number of columns (this should match the arrays).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6023 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6024 int API dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6025 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6026 LV_COLUMN lvc;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6027
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6028 lvc.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6029 lvc.pszText = "Filename";
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6030 lvc.cchTextMax = 8;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6031 lvc.fmt = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6032 if(!count)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6033 lvc.cx = 300;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6034 else
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6035 lvc.cx = 150;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6036 lvc.iSubItem = count;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6037 SendMessage(handle, LVM_INSERTCOLUMN, (WPARAM)0, (LPARAM)&lvc);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6038 dw_container_setup(handle, flags, titles, count, -1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6039 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6040 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6041
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6042 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6043 * Obtains an icon from a module (or header in GTK).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6044 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6045 * module: Handle to module (DLL) in OS/2 and Windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6046 * id: A unsigned long id int the resources on OS/2 and
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6047 * Windows, on GTK this is converted to a pointer
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6048 * to an embedded XPM.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6049 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6050 unsigned long API dw_icon_load(unsigned long module, unsigned long id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6051 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6052 return (unsigned long)LoadIcon(DWInstance, MAKEINTRESOURCE(id));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6053 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6054
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6055 /*
257
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
6056 * Obtains an icon from a file.
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
6057 * Parameters:
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
6058 * filename: Name of the file, omit extention to have
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
6059 * DW pick the appropriate file extension.
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
6060 * (ICO on OS/2 or Windows, XPM on Unix)
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
6061 */
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
6062 unsigned long API dw_icon_load_from_file(char *filename)
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
6063 {
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
6064 char *file = malloc(strlen(filename) + 5);
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
6065 HANDLE icon;
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
6066
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
6067 if(!file)
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
6068 return 0;
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
6069
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
6070 strcpy(file, filename);
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
6071
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
6072 /* check if we can read from this file (it exists and read permission) */
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
6073 if(access(file, 04) != 0)
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
6074 {
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
6075 /* Try with .bmp extention */
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
6076 strcat(file, ".ico");
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
6077 if(access(file, 04) != 0)
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
6078 {
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
6079 free(file);
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
6080 return 0;
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
6081 }
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
6082 }
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
6083 icon = LoadImage(NULL, file, IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
6084 free(file);
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
6085 return (unsigned long)icon;
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
6086 }
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
6087
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 248
diff changeset
6088 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6089 * Frees a loaded resource in OS/2 and Windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6090 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6091 * handle: Handle to icon returned by dw_icon_load().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6092 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6093 void API dw_icon_free(unsigned long handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6094 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6095 DestroyIcon((HICON)handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6096 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6097
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6098 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6099 * Allocates memory used to populate a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6100 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6101 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6102 * rowcount: The number of items to be populated.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6103 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6104 void * API dw_container_alloc(HWND handle, int rowcount)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6105 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6106 LV_ITEM lvi;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6107 int z;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6108
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6109 lvi.mask = LVIF_DI_SETITEM | LVIF_TEXT | LVIF_IMAGE;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6110 lvi.iSubItem = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6111 /* Insert at the end */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6112 lvi.iItem = 1000000;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6113 lvi.pszText = "";
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6114 lvi.cchTextMax = 1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6115 lvi.iImage = -1;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
6116
79
8082cb0e7c2e Updated to the latest DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 75
diff changeset
6117 ShowWindow(handle, SW_HIDE);
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
6118 for(z=0;z<rowcount;z++)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6119 ListView_InsertItem(handle, &lvi);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6120 return (void *)handle;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6121 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6122
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6123 /* Finds a icon in the table, otherwise it adds it to the table
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6124 * and returns the index in the table.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6125 */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6126 int _lookup_icon(HWND handle, HICON hicon, int type)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6127 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6128 int z;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6129 static HWND lasthwnd = NULL;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6130
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6131 if(!hSmall || !hLarge)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6132 {
67
ab9b0fa6c66e Focus fixes and removal of several hack in the OS/2 code base.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 63
diff changeset
6133 hSmall = ImageList_Create(16, 16, ILC_COLOR16 | ILC_MASK, ICON_INDEX_LIMIT, 0);
ab9b0fa6c66e Focus fixes and removal of several hack in the OS/2 code base.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 63
diff changeset
6134 hLarge = ImageList_Create(32, 32, ILC_COLOR16 | ILC_MASK, ICON_INDEX_LIMIT, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6135 }
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6136 for(z=0;z<ICON_INDEX_LIMIT;z++)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6137 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6138 if(!lookup[z])
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6139 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6140 lookup[z] = hicon;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6141 ImageList_AddIcon(hSmall, hicon);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6142 ImageList_AddIcon(hLarge, hicon);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6143 if(type)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6144 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6145 TreeView_SetImageList(handle, hSmall, TVSIL_NORMAL);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6146 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6147 else
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6148 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6149 ListView_SetImageList(handle, hSmall, LVSIL_SMALL);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6150 ListView_SetImageList(handle, hLarge, LVSIL_NORMAL);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6151 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6152 lasthwnd = handle;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6153 return z;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6154 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6155
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6156 if(hicon == lookup[z])
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6157 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6158 if(lasthwnd != handle)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6159 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6160 if(type)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6161 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6162 TreeView_SetImageList(handle, hSmall, TVSIL_NORMAL);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6163 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6164 else
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6165 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6166 ListView_SetImageList(handle, hSmall, LVSIL_SMALL);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6167 ListView_SetImageList(handle, hLarge, LVSIL_NORMAL);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6168 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6169 lasthwnd = handle;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6170 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6171 return z;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6172 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6173 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6174 return -1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6175 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6176
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6177 /*
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6178 * Sets an item in specified row and column to the given data.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6179 * Parameters:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6180 * handle: Handle to the container window (widget).
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6181 * pointer: Pointer to the allocated memory in dw_container_alloc().
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6182 * column: Zero based column of data being set.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6183 * row: Zero based row of data being set.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6184 * data: Pointer to the data to be added.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6185 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6186 void API dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, unsigned long icon)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6187 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6188 LV_ITEM lvi;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6189
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6190 lvi.iItem = row;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6191 lvi.iSubItem = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6192 lvi.mask = LVIF_DI_SETITEM | LVIF_IMAGE | LVIF_TEXT;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6193 lvi.pszText = filename;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6194 lvi.cchTextMax = strlen(filename);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6195 lvi.iImage = _lookup_icon(handle, (HICON)icon, 0);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6196
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6197 ListView_SetItem(handle, &lvi);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6198 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6199
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6200 /*
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6201 * Sets an item in specified row and column to the given data.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6202 * Parameters:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6203 * handle: Handle to the container window (widget).
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6204 * pointer: Pointer to the allocated memory in dw_container_alloc().
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6205 * column: Zero based column of data being set.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6206 * row: Zero based row of data being set.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6207 * data: Pointer to the data to be added.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6208 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6209 void API dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6210 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6211 dw_container_set_item(handle, pointer, column + 1, row, data);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6212 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6213
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6214 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6215 * Sets an item in specified row and column to the given data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6216 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6217 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6218 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6219 * column: Zero based column of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6220 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6221 * data: Pointer to the data to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6222 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6223 void API dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6224 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6225 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLong(handle, GWL_USERDATA);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6226 ULONG *flags;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6227 LV_ITEM lvi;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6228 char textbuffer[100], *destptr = textbuffer;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6229
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6230 if(!cinfo || !cinfo->flags || !data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6231 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6232
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6233 flags = cinfo->flags;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6234
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6235 lvi.mask = LVIF_DI_SETITEM | LVIF_TEXT;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6236 lvi.iItem = row;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6237 lvi.iSubItem = column;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6238
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6239 if(flags[column] & DW_CFA_BITMAPORICON)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6240 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6241 HICON hicon = *((HICON *)data);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6242
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6243 lvi.mask = LVIF_DI_SETITEM | LVIF_IMAGE;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6244 lvi.pszText = NULL;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6245 lvi.cchTextMax = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6246
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6247 lvi.iImage = _lookup_icon(handle, hicon, 0);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6248 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6249 else if(flags[column] & DW_CFA_STRING)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6250 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6251 char *tmp = *((char **)data);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6252
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6253 if(!tmp)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6254 tmp = "";
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6255
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6256 lvi.pszText = tmp;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6257 lvi.cchTextMax = strlen(tmp);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6258 destptr = tmp;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6259 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6260 else if(flags[column] & DW_CFA_ULONG)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6261 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6262 ULONG tmp = *((ULONG *)data);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6263
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6264 sprintf(textbuffer, "%lu", tmp);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6265
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6266 lvi.pszText = textbuffer;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6267 lvi.cchTextMax = strlen(textbuffer);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6268 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6269 else if(flags[column] & DW_CFA_DATE)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6270 {
165
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 161
diff changeset
6271 struct tm curtm;
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 161
diff changeset
6272 CDATE cdate = *((CDATE *)data);
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 161
diff changeset
6273
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 161
diff changeset
6274 curtm.tm_mday = cdate.day;
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 161
diff changeset
6275 curtm.tm_mon = cdate.month - 1;
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 161
diff changeset
6276 curtm.tm_year = cdate.year - 1900;
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 161
diff changeset
6277
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 161
diff changeset
6278 strftime(textbuffer, 100, "%x", &curtm);
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 161
diff changeset
6279
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6280 lvi.pszText = textbuffer;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6281 lvi.cchTextMax = strlen(textbuffer);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6282 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6283 else if(flags[column] & DW_CFA_TIME)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6284 {
165
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 161
diff changeset
6285 struct tm curtm;
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 161
diff changeset
6286 CTIME ctime = *((CTIME *)data);
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 161
diff changeset
6287
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 161
diff changeset
6288 curtm.tm_hour = ctime.hours;
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 161
diff changeset
6289 curtm.tm_min = ctime.minutes;
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 161
diff changeset
6290 curtm.tm_sec = ctime.seconds;
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 161
diff changeset
6291
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 161
diff changeset
6292 strftime(textbuffer, 100, "%X", &curtm);
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 161
diff changeset
6293
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6294 lvi.pszText = textbuffer;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6295 lvi.cchTextMax = strlen(textbuffer);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6296 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6297
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6298 ListView_SetItem(handle, &lvi);
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6299 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6300
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6301 /*
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6302 * Changes an existing item in specified row and column to the given data.
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6303 * Parameters:
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6304 * handle: Handle to the container window (widget).
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6305 * column: Zero based column of data being set.
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6306 * row: Zero based row of data being set.
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6307 * data: Pointer to the data to be added.
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6308 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6309 void API dw_container_change_item(HWND handle, int column, int row, void *data)
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6310 {
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6311 dw_container_set_item(handle, NULL, column, row, data);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6312 }
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6313
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6314 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6315 * Sets the width of a column in the container.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6316 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6317 * handle: Handle to window (widget) of container.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6318 * column: Zero based column of width being set.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6319 * width: Width of column in pixels.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6320 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6321 void API dw_container_set_column_width(HWND handle, int column, int width)
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6322 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6323 ListView_SetColumnWidth(handle, column, width);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6324 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6325
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6326 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6327 * Sets the title of a row in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6328 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6329 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6330 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6331 * title: String title of the item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6332 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6333 void API dw_container_set_row_title(void *pointer, int row, char *title)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6334 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6335 LV_ITEM lvi;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6336 HWND container = (HWND)pointer;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6337
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6338 lvi.iItem = row;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6339 lvi.iSubItem = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6340 lvi.mask = LVIF_PARAM;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6341 lvi.lParam = (LPARAM)title;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6342
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6343 if(!ListView_SetItem(container, &lvi) && lvi.lParam)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6344 lvi.lParam = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6345
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6346 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6347
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6348 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6349 * Sets the title of a row in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6350 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6351 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6352 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6353 * rowcount: The number of rows to be inserted.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6354 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6355 void API dw_container_insert(HWND handle, void *pointer, int rowcount)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6356 {
79
8082cb0e7c2e Updated to the latest DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 75
diff changeset
6357 ShowWindow(handle, SW_SHOW);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6358 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6359
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6360 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6361 * Removes all rows from a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6362 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6363 * handle: Handle to the window (widget) to be cleared.
52
0804483f6320 Added a redraw parameter to dw_container_clear().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 49
diff changeset
6364 * redraw: TRUE to cause the container to redraw immediately.
0804483f6320 Added a redraw parameter to dw_container_clear().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 49
diff changeset
6365 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6366 void API dw_container_clear(HWND handle, int redraw)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6367 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6368 ListView_DeleteAllItems(handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6369 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6370
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6371 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6372 * Removes the first x rows from a container.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6373 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6374 * handle: Handle to the window (widget) to be deleted from.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6375 * rowcount: The number of rows to be deleted.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6376 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6377 void API dw_container_delete(HWND handle, int rowcount)
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6378 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6379 int z;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6380
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6381 for(z=0;z<rowcount;z++)
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6382 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6383 ListView_DeleteItem(handle, 0);
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6384 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6385 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6386
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6387 /*
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6388 * Scrolls container up or down.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6389 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6390 * handle: Handle to the window (widget) to be scrolled.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6391 * direction: DW_SCROLL_UP, DW_SCROLL_DOWN, DW_SCROLL_TOP or
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6392 * DW_SCROLL_BOTTOM. (rows is ignored for last two)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6393 * rows: The number of rows to be scrolled.
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6394 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6395 void API dw_container_scroll(HWND handle, int direction, long rows)
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6396 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6397 switch(direction)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6398 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6399 case DW_SCROLL_TOP:
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6400 ListView_Scroll(handle, 0, -10000000);
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6401 break;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6402 case DW_SCROLL_BOTTOM:
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6403 ListView_Scroll(handle, 0, 10000000);
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6404 break;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6405 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6406 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6407
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
6408 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6409 * Starts a new query of a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6410 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6411 * handle: Handle to the window (widget) to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6412 * flags: If this parameter is DW_CRA_SELECTED it will only
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6413 * return items that are currently selected. Otherwise
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6414 * it will return all records in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6415 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6416 char * API dw_container_query_start(HWND handle, unsigned long flags)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6417 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6418 LV_ITEM lvi;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6419
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6420 _index = ListView_GetNextItem(handle, -1, flags);
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6421
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6422 if(_index == -1)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6423 return NULL;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6424
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6425 memset(&lvi, 0, sizeof(LV_ITEM));
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6426
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6427 lvi.iItem = _index;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6428 lvi.mask = LVIF_PARAM;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6429
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6430 ListView_GetItem(handle, &lvi);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6431
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6432 return (char *)lvi.lParam;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6433 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6434
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6435 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6436 * Continues an existing query of a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6437 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6438 * handle: Handle to the window (widget) to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6439 * flags: If this parameter is DW_CRA_SELECTED it will only
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6440 * return items that are currently selected. Otherwise
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6441 * it will return all records in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6442 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6443 char * API dw_container_query_next(HWND handle, unsigned long flags)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6444 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6445 LV_ITEM lvi;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6446
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6447 _index = ListView_GetNextItem(handle, _index, flags);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6448
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6449 if(_index == -1)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6450 return NULL;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6451
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6452 memset(&lvi, 0, sizeof(LV_ITEM));
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6453
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6454 lvi.iItem = _index;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6455 lvi.mask = LVIF_PARAM;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6456
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6457 ListView_GetItem(handle, &lvi);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6458
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6459 return (char *)lvi.lParam;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6460 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6461
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6462 /*
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6463 * Cursors the item with the text speficied, and scrolls to that item.
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6464 * Parameters:
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6465 * handle: Handle to the window (widget) to be queried.
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6466 * text: Text usually returned by dw_container_query().
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6467 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6468 void API dw_container_cursor(HWND handle, char *text)
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6469 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6470 int index = ListView_GetNextItem(handle, -1, LVNI_ALL);
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6471
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6472 while(index != -1)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6473 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6474 LV_ITEM lvi;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6475
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6476 memset(&lvi, 0, sizeof(LV_ITEM));
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6477
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6478 lvi.iItem = index;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6479 lvi.mask = LVIF_PARAM;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6480
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6481 ListView_GetItem(handle, &lvi);
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6482
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6483 if((char *)lvi.lParam == text)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6484 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6485 RECT viewport, item;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6486
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6487 ListView_SetItemState(handle, index, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED);
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6488 ListView_EnsureVisible(handle, index, TRUE);
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6489 return;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6490 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6491
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6492 index = ListView_GetNextItem(handle, index, LVNI_ALL);
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6493 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6494 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6495
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6496 /*
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6497 * Deletes the item with the text speficied.
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6498 * Parameters:
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6499 * handle: Handle to the window (widget).
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6500 * text: Text usually returned by dw_container_query().
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6501 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6502 void API dw_container_delete_row(HWND handle, char *text)
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6503 {
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6504 int index = ListView_GetNextItem(handle, -1, LVNI_ALL);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6505
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6506 while(index != -1)
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6507 {
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6508 LV_ITEM lvi;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6509
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6510 memset(&lvi, 0, sizeof(LV_ITEM));
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6511
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6512 lvi.iItem = index;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6513 lvi.mask = LVIF_PARAM;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6514
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6515 ListView_GetItem(handle, &lvi);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6516
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6517 if((char *)lvi.lParam == text)
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6518 {
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6519 ListView_DeleteItem(handle, index);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6520 return;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6521 }
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6522
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6523 index = ListView_GetNextItem(handle, index, LVNI_ALL);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6524 }
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6525 }
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6526
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6527 /*
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6528 * Optimizes the column widths so that all data is visible.
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6529 * Parameters:
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6530 * handle: Handle to the window (widget) to be optimized.
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6531 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6532 void API dw_container_optimize(HWND handle)
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6533 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6534 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLong(handle, GWL_USERDATA);
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6535 ULONG *flags;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6536 LV_ITEM lvi;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6537
102
372a7581b312 Minor changes to the container code on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 95
diff changeset
6538 if(cinfo && cinfo->columns == 1)
372a7581b312 Minor changes to the container code on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 95
diff changeset
6539 {
372a7581b312 Minor changes to the container code on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 95
diff changeset
6540 ListView_SetColumnWidth(handle, 0, LVSCW_AUTOSIZE);
372a7581b312 Minor changes to the container code on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 95
diff changeset
6541 }
372a7581b312 Minor changes to the container code on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 95
diff changeset
6542 else if(cinfo && cinfo->columns > 1)
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6543 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6544 int z, index;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6545 ULONG *flags = cinfo->flags, *columns = calloc(sizeof(ULONG), cinfo->columns);
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6546 char *text = malloc(1024);
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6547
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6548 /* Initialize with sizes of column labels */
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6549 for(z=0;z<cinfo->columns;z++)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6550 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6551 if(flags[z] & DW_CFA_BITMAPORICON)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6552 columns[z] = 5;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6553 else
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6554 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6555 LVCOLUMN lvc;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6556
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6557 lvc.mask = LVCF_TEXT;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6558 lvc.cchTextMax = 1023;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6559 lvc.pszText = text;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6560
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6561 if(ListView_GetColumn(handle, z, &lvc))
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6562 columns[z] = ListView_GetStringWidth(handle, lvc.pszText);
105
ad95fc623ff3 Some changes to the container optimization code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 104
diff changeset
6563
ad95fc623ff3 Some changes to the container optimization code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 104
diff changeset
6564 if(flags[z] & DW_CFA_RESERVED)
ad95fc623ff3 Some changes to the container optimization code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 104
diff changeset
6565 columns[z] += 20;
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6566 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6567 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6568
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6569 index = ListView_GetNextItem(handle, -1, LVNI_ALL);
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6570
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6571 /* Query all the item texts */
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6572 while(index != -1)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6573 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6574 for(z=0;z<cinfo->columns;z++)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6575 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6576 LV_ITEM lvi;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6577
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6578 memset(&lvi, 0, sizeof(LV_ITEM));
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6579
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6580 lvi.iItem = index;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6581 lvi.iSubItem = z;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6582 lvi.mask = LVIF_TEXT;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6583 lvi.cchTextMax = 1023;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6584 lvi.pszText = text;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6585
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6586 if(ListView_GetItem(handle, &lvi))
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6587 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6588 int width = ListView_GetStringWidth(handle, lvi.pszText);
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6589 if(width > columns[z])
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6590 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6591 if(z == 0)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6592 columns[z] = width + 20;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6593 else
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6594 columns[z] = width;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6595 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6596 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6597 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6598
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6599 index = ListView_GetNextItem(handle, index, LVNI_ALL);
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6600 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6601
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6602 /* Set the new sizes */
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6603 for(z=0;z<cinfo->columns;z++)
71
291c30a92b9b Fixed a bug where if dw_filesystem_* was used then the last column
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
6604 ListView_SetColumnWidth(handle, z, columns[z] + 16);
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6605
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6606 free(columns);
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6607 free(text);
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6608 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6609 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6610
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
6611 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6612 * Creates a rendering context widget (window) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6613 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6614 * id: An id to be used with dw_window_from_id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6615 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6616 * A handle to the widget or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6617 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6618 HWND API dw_render_new(unsigned long id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6619 {
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
6620 Box *newbox = calloc(sizeof(Box), 1);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6621 HWND tmp = CreateWindow(ObjectClassName,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6622 "",
107
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 106
diff changeset
6623 WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN,
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6624 0,0,2000,1000,
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6625 DW_HWND_OBJECT,
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 118
diff changeset
6626 (HMENU)id,
109
94d273843a41 Use DWInstance, and some updates to the spinbutton hack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
6627 DWInstance,
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6628 NULL);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6629 newbox->pad = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6630 newbox->type = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6631 newbox->count = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6632 newbox->grouphwnd = (HWND)NULL;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6633 newbox->cinfo.pOldProc = SubclassWindow(tmp, _rendwndproc);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6634 newbox->cinfo.fore = newbox->cinfo.back = -1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6635
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6636 SetWindowLong(tmp, GWL_USERDATA, (ULONG)newbox);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6637 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6638 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6639
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6640 /* Sets the current foreground drawing color.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6641 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6642 * red: red value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6643 * green: green value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6644 * blue: blue value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6645 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6646 void API dw_color_foreground_set(unsigned long value)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6647 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6648 int threadid = dw_thread_id();
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6649
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6650 if(threadid < 0 || threadid >= THREAD_LIMIT)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6651 threadid = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6652
191
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
6653 value = _internal_color(value);
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
6654
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6655 DeleteObject(_hPen[threadid]);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6656 DeleteObject(_hBrush[threadid]);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6657 _foreground[threadid] = RGB(DW_RED_VALUE(value), DW_GREEN_VALUE(value), DW_BLUE_VALUE(value));
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6658 _hPen[threadid] = CreatePen(PS_SOLID, 1, _foreground[threadid]);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6659 _hBrush[threadid] = CreateSolidBrush(_foreground[threadid]);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6660 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6661
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6662 /* Sets the current background drawing color.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6663 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6664 * red: red value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6665 * green: green value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6666 * blue: blue value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6667 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6668 void API dw_color_background_set(unsigned long value)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6669 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6670 int threadid = dw_thread_id();
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6671
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6672 if(threadid < 0 || threadid >= THREAD_LIMIT)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6673 threadid = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6674
191
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
6675 value = _internal_color(value);
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
6676
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6677 _background[threadid] = RGB(DW_RED_VALUE(value), DW_GREEN_VALUE(value), DW_BLUE_VALUE(value));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6678 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6679
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6680 /* Draw a point on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6681 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6682 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6683 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6684 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6685 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6686 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6687 void API dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6688 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6689 HDC hdcPaint;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6690 int threadid = dw_thread_id();
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6691
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6692 if(threadid < 0 || threadid >= THREAD_LIMIT)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6693 threadid = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6694
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6695 if(handle)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6696 hdcPaint = GetDC(handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6697 else if(pixmap)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6698 hdcPaint = pixmap->hdc;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6699 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6700 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6701
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6702 SetPixel(hdcPaint, x, y, _foreground[threadid]);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6703 if(!pixmap)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6704 ReleaseDC(handle, hdcPaint);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6705 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6706
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6707 /* Draw a line on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6708 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6709 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6710 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6711 * x1: First X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6712 * y1: First Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6713 * x2: Second X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6714 * y2: Second Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6715 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6716 void API dw_draw_line(HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6717 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6718 HDC hdcPaint;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6719 HPEN oldPen;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6720 int threadid = dw_thread_id();
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6721
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6722 if(threadid < 0 || threadid >= THREAD_LIMIT)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6723 threadid = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6724
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6725 if(handle)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6726 hdcPaint = GetDC(handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6727 else if(pixmap)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6728 hdcPaint = pixmap->hdc;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6729 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6730 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6731
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6732 oldPen = SelectObject(hdcPaint, _hPen[threadid]);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6733 MoveToEx(hdcPaint, x1, y1, NULL);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6734 LineTo(hdcPaint, x2, y2);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6735 SelectObject(hdcPaint, oldPen);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6736 /* For some reason Win98 (at least) fails
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6737 * to draw the last pixel. So I do it myself.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6738 */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6739 SetPixel(hdcPaint, x2, y2, _foreground[threadid]);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6740 if(!pixmap)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6741 ReleaseDC(handle, hdcPaint);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6742 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6743
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6744 /* Draw a rectangle on a window (preferably a render window).
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6745 * Parameters:
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6746 * handle: Handle to the window.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6747 * pixmap: Handle to the pixmap. (choose only one of these)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6748 * x: X coordinate.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6749 * y: Y coordinate.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6750 * width: Width of rectangle.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6751 * height: Height of rectangle.
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6752 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6753 void API dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6754 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6755 HDC hdcPaint;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6756 HPEN oldPen;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6757 HBRUSH oldBrush;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6758 int threadid = dw_thread_id();
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6759
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6760 if(threadid < 0 || threadid >= THREAD_LIMIT)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6761 threadid = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6762
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6763 if(handle)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6764 hdcPaint = GetDC(handle);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6765 else if(pixmap)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6766 hdcPaint = pixmap->hdc;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6767 else
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6768 return;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6769
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6770 oldPen = SelectObject(hdcPaint, _hPen[threadid]);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6771 oldBrush = SelectObject(hdcPaint, _hBrush[threadid]);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6772 Rectangle(hdcPaint, x, y, x + width, y + height);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6773 SelectObject(hdcPaint, oldPen);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6774 SelectObject(hdcPaint, oldBrush);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6775 if(!pixmap)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6776 ReleaseDC(handle, hdcPaint);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6777 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6778
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6779 /* Draw text on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6780 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6781 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6782 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6783 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6784 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6785 * text: Text to be displayed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6786 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6787 void API dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6788 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6789 HDC hdc;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6790 int size = 9, z, mustdelete = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6791 HFONT hFont, oldFont;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6792 int threadid = dw_thread_id();
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6793
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6794 if(threadid < 0 || threadid >= THREAD_LIMIT)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6795 threadid = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6796
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6797 if(handle)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6798 hdc = GetDC(handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6799 else if(pixmap)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6800 hdc = pixmap->hdc;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6801 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6802 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6803
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6804 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6805 ColorInfo *cinfo;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6806
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6807 if(handle)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6808 cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6809 else
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6810 cinfo = (ColorInfo *)GetWindowLong(pixmap->handle, GWL_USERDATA);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6811
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6812 if(cinfo)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6813 {
67
ab9b0fa6c66e Focus fixes and removal of several hack in the OS/2 code base.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 63
diff changeset
6814 hFont = _acquire_font(handle, cinfo->fontname);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6815 mustdelete = 1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6816 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6817 }
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6818 oldFont = SelectObject(hdc, hFont);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6819 SetTextColor(hdc, _foreground[threadid]);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6820 SetBkMode(hdc, TRANSPARENT);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6821 TextOut(hdc, x, y, text, strlen(text));
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6822 SelectObject(hdc, oldFont);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6823 if(mustdelete)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6824 DeleteObject(hFont);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6825 if(!pixmap)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6826 ReleaseDC(handle, hdc);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6827 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6828
49
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
6829 /* Query the width and height of a text string.
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
6830 * Parameters:
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
6831 * handle: Handle to the window.
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
6832 * pixmap: Handle to the pixmap. (choose only one of these)
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
6833 * text: Text to be queried.
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
6834 * width: Pointer to a variable to be filled in with the width.
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
6835 * height Pointer to a variable to be filled in with the height.
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
6836 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6837 void API dw_font_text_extents(HWND handle, HPIXMAP pixmap, char *text, int *width, int *height)
49
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
6838 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6839 HDC hdc;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6840 int mustdelete = 0;
88
58d8139fe0a2 Added vertical center logic for static text controls on windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
6841 HFONT hFont = NULL, oldFont;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6842 SIZE sz;
49
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
6843
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
6844 if(handle)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6845 hdc = GetDC(handle);
49
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
6846 else if(pixmap)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6847 hdc = pixmap->hdc;
49
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
6848 else
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
6849 return;
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
6850
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6851 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6852 ColorInfo *cinfo;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6853
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6854 if(handle)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6855 cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6856 else
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6857 cinfo = (ColorInfo *)GetWindowLong(pixmap->handle, GWL_USERDATA);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6858
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6859 if(cinfo)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6860 {
67
ab9b0fa6c66e Focus fixes and removal of several hack in the OS/2 code base.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 63
diff changeset
6861 hFont = _acquire_font(handle, cinfo->fontname);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6862 mustdelete = 1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6863 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6864 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6865 oldFont = SelectObject(hdc, hFont);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6866
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6867 GetTextExtentPoint32(hdc, text, strlen(text), &sz);
49
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
6868
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
6869 if(width)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6870 *width = sz.cx;
49
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
6871
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
6872 if(height)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6873 *height = sz.cy;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6874
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6875 SelectObject(hdc, oldFont);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6876 if(mustdelete)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6877 DeleteObject(hFont);
49
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
6878 if(!pixmap)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6879 ReleaseDC(handle, hdc);
49
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
6880 }
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
6881
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6882 /* Call this after drawing to the screen to make sure
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6883 * anything you have drawn is visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6884 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6885 void API dw_flush(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6886 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6887 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6888
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6889 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6890 * Creates a pixmap with given parameters.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6891 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6892 * handle: Window handle the pixmap is associated with.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6893 * width: Width of the pixmap in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6894 * height: Height of the pixmap in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6895 * depth: Color depth of the pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6896 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6897 * A handle to a pixmap or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6898 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6899 HPIXMAP API dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6900 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6901 HPIXMAP pixmap;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6902 BITMAP bm;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6903 HDC hdc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6904
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6905 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6906 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6907
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6908 hdc = GetDC(handle);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6909
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6910 pixmap->width = width; pixmap->height = height;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6911
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6912 pixmap->handle = handle;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6913 pixmap->hbm = CreateCompatibleBitmap(hdc, width, height);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6914 pixmap->hdc = CreateCompatibleDC(hdc);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6915
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6916 SelectObject(pixmap->hdc, pixmap->hbm);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6917
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6918 ReleaseDC(handle, hdc);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6919
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6920 return pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6921 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6922
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6923 /*
241
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6924 * Creates a pixmap from a file.
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6925 * Parameters:
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6926 * handle: Window handle the pixmap is associated with.
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6927 * filename: Name of the file, omit extention to have
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6928 * DW pick the appropriate file extension.
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6929 * (BMP on OS/2 or Windows, XPM on Unix)
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6930 * Returns:
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6931 * A handle to a pixmap or NULL on failure.
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6932 */
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6933 HPIXMAP API dw_pixmap_new_from_file(HWND handle, char *filename)
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6934 {
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6935 HPIXMAP pixmap;
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6936 BITMAP bm;
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6937 HDC hdc;
242
36013ddd3f5b Fixes for Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 241
diff changeset
6938 char *file = malloc(strlen(filename) + 5);
241
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6939
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6940 if (!file || !(pixmap = calloc(1,sizeof(struct _hpixmap))))
242
36013ddd3f5b Fixes for Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 241
diff changeset
6941 {
36013ddd3f5b Fixes for Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 241
diff changeset
6942 if(file)
36013ddd3f5b Fixes for Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 241
diff changeset
6943 free(file);
241
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6944 return NULL;
242
36013ddd3f5b Fixes for Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 241
diff changeset
6945 }
241
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6946
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6947 strcpy(file, filename);
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6948
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6949 /* check if we can read from this file (it exists and read permission) */
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6950 if(access(file, 04) != 0)
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6951 {
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6952 /* Try with .bmp extention */
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6953 strcat(file, ".bmp");
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6954 if(access(file, 04) != 0)
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6955 {
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6956 free(pixmap);
242
36013ddd3f5b Fixes for Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 241
diff changeset
6957 free(file);
241
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6958 return NULL;
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6959 }
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6960 }
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6961
242
36013ddd3f5b Fixes for Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 241
diff changeset
6962 hdc = GetDC(handle);
241
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6963
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6964 pixmap->handle = handle;
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6965 pixmap->hbm = (HBITMAP)LoadImage(NULL, file, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
242
36013ddd3f5b Fixes for Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 241
diff changeset
6966
36013ddd3f5b Fixes for Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 241
diff changeset
6967 if(!pixmap->hbm)
36013ddd3f5b Fixes for Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 241
diff changeset
6968 {
36013ddd3f5b Fixes for Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 241
diff changeset
6969 free(file);
36013ddd3f5b Fixes for Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 241
diff changeset
6970 free(pixmap);
36013ddd3f5b Fixes for Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 241
diff changeset
6971 ReleaseDC(handle, hdc);
36013ddd3f5b Fixes for Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 241
diff changeset
6972 return NULL;
36013ddd3f5b Fixes for Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 241
diff changeset
6973 }
36013ddd3f5b Fixes for Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 241
diff changeset
6974
241
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6975 pixmap->hdc = CreateCompatibleDC(hdc);
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6976
243
3c1e39905f2f Use GetObject() instead of GetBitmapDimensionEx() to get the loaded bitmap
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 242
diff changeset
6977 GetObject(pixmap->hbm, sizeof(bm), &bm);
3c1e39905f2f Use GetObject() instead of GetBitmapDimensionEx() to get the loaded bitmap
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 242
diff changeset
6978
3c1e39905f2f Use GetObject() instead of GetBitmapDimensionEx() to get the loaded bitmap
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 242
diff changeset
6979 pixmap->width = bm.bmWidth; pixmap->height = bm.bmHeight;
242
36013ddd3f5b Fixes for Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 241
diff changeset
6980
241
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6981 SelectObject(pixmap->hdc, pixmap->hbm);
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6982
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6983 ReleaseDC(handle, hdc);
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6984
242
36013ddd3f5b Fixes for Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 241
diff changeset
6985 free(file);
36013ddd3f5b Fixes for Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 241
diff changeset
6986
241
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6987 return pixmap;
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6988 }
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6989
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
6990 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6991 * Creates a pixmap from internal resource graphic specified by id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6992 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6993 * handle: Window handle the pixmap is associated with.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6994 * id: Resource ID associated with requested pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6995 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6996 * A handle to a pixmap or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6997 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6998 HPIXMAP API dw_pixmap_grab(HWND handle, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6999 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7000 HPIXMAP pixmap;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7001 BITMAP bm;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7002 HDC hdc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7003
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7004 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7005 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7006
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7007 hdc = GetDC(handle);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7008
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7009
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7010 pixmap->hbm = LoadBitmap(DWInstance, MAKEINTRESOURCE(id));
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7011 pixmap->hdc = CreateCompatibleDC(hdc);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7012
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7013 GetObject(pixmap->hbm, sizeof(BITMAP), (void *)&bm);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7014
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7015 pixmap->width = bm.bmWidth; pixmap->height = bm.bmHeight;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7016
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7017 SelectObject(pixmap->hdc, pixmap->hbm);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7018
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7019 ReleaseDC(handle, hdc);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7020
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7021 return pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7022 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7023
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7024 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7025 * Destroys an allocated pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7026 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7027 * pixmap: Handle to a pixmap returned by
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7028 * dw_pixmap_new..
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7029 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7030 void API dw_pixmap_destroy(HPIXMAP pixmap)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7031 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7032 if(pixmap)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7033 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7034 DeleteDC(pixmap->hdc);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7035 DeleteObject(pixmap->hbm);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7036 free(pixmap);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7037 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7038 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7039
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7040 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7041 * Copies from one item to another.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7042 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7043 * dest: Destination window handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7044 * destp: Destination pixmap. (choose only one).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7045 * xdest: X coordinate of destination.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7046 * ydest: Y coordinate of destination.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7047 * width: Width of area to copy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7048 * height: Height of area to copy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7049 * src: Source window handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7050 * srcp: Source pixmap. (choose only one).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7051 * xsrc: X coordinate of source.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7052 * ysrc: Y coordinate of source.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7053 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7054 void API dw_pixmap_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7055 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7056 HDC hdcdest;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7057 HDC hdcsrc;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7058
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7059 if(dest)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7060 hdcdest = GetDC(dest);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7061 else if(destp)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7062 hdcdest = destp->hdc;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7063 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7064 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7065
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7066 if(src)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7067 hdcsrc = GetDC(src);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7068 else if(srcp)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7069 hdcsrc = srcp->hdc;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7070 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7071 return;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7072
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7073 BitBlt(hdcdest, xdest, ydest, width, height, hdcsrc, xsrc, ysrc, SRCCOPY);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7074
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7075 if(!destp)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7076 ReleaseDC(dest, hdcdest);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7077 if(!srcp)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7078 ReleaseDC(src, hdcsrc);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7079 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7080
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7081 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7082 * Emits a beep.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7083 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7084 * freq: Frequency.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7085 * dur: Duration.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7086 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7087 void API dw_beep(int freq, int dur)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7088 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7089 Beep(freq, dur);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7090 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7091
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7092 /* Open a shared library and return a handle.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7093 * Parameters:
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7094 * name: Base name of the shared library.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7095 * handle: Pointer to a module handle,
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7096 * will be filled in with the handle.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7097 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7098 int API dw_module_load(char *name, HMOD *handle)
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7099 {
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7100 if(!handle)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7101 return -1;
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7102
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7103 *handle = LoadLibrary(name);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7104 return (NULL == *handle);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7105 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7106
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7107 /* Queries the address of a symbol within open handle.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7108 * Parameters:
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7109 * handle: Module handle returned by dw_module_load()
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7110 * name: Name of the symbol you want the address of.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7111 * func: A pointer to a function pointer, to obtain
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7112 * the address.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7113 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7114 int API dw_module_symbol(HMOD handle, char *name, void**func)
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7115 {
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7116 if(!func || !name)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7117 return -1;
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7118
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7119 if(0 == strlen(name))
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7120 return -1;
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7121
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7122 *func = (void*)GetProcAddress(handle, name);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7123 return (NULL == *func);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7124 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7125
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7126 /* Frees the shared library previously opened.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7127 * Parameters:
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7128 * handle: Module handle returned by dw_module_load()
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7129 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7130 int API dw_module_close(HMOD handle)
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7131 {
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7132 return FreeLibrary(handle);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7133 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7134
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7135 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7136 * Returns the handle to an unnamed mutex semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7137 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7138 HMTX API dw_mutex_new(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7139 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7140 return (HMTX)CreateMutex(NULL, FALSE, NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7141 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7142
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7143 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7144 * Closes a semaphore created by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7145 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7146 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7147 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7148 void API dw_mutex_close(HMTX mutex)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7149 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7150 CloseHandle((HANDLE)mutex);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7151 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7152
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7153 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7154 * Tries to gain access to the semaphore, if it can't it blocks.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7155 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7156 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7157 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7158 void API dw_mutex_lock(HMTX mutex)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7159 {
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
7160 if(_dwtid == dw_thread_id())
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
7161 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
7162 int rc = WaitForSingleObject((HANDLE)mutex, 0);
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
7163
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
7164 while(rc == WAIT_TIMEOUT)
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
7165 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
7166 dw_main_sleep(1);
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
7167 rc = WaitForSingleObject((HANDLE)mutex, 0);
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
7168 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
7169 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
7170 else
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
7171 WaitForSingleObject((HANDLE)mutex, INFINITE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7172 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7173
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7174 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7175 * Reliquishes the access to the semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7176 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7177 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7178 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7179 void API dw_mutex_unlock(HMTX mutex)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7180 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7181 ReleaseMutex((HANDLE)mutex);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7182 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7183
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7184 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7185 * Returns the handle to an unnamed event semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7186 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7187 HEV API dw_event_new(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7188 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7189 return CreateEvent(NULL, TRUE, FALSE, NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7190 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7191
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7192 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7193 * Resets a semaphore created by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7194 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7195 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7196 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7197 int API dw_event_reset(HEV eve)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7198 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7199 return ResetEvent(eve);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7200 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7201
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7202 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7203 * Posts a semaphore created by dw_event_new(). Causing all threads
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7204 * waiting on this event in dw_event_wait to continue.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7205 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7206 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7207 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7208 int API dw_event_post(HEV eve)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7209 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7210 return SetEvent(eve);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7211 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7212
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7213 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7214 * Waits on a semaphore created by dw_event_new(), until the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7215 * event gets posted or until the timeout expires.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7216 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7217 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7218 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7219 int API dw_event_wait(HEV eve, unsigned long timeout)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7220 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7221 int rc;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7222
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7223 rc = WaitForSingleObject(eve, timeout);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7224 if(rc == WAIT_OBJECT_0)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7225 return 1;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7226 if(rc == WAIT_ABANDONED)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7227 return -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7228 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7229 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7230
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7231 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7232 * Closes a semaphore created by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7233 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7234 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7235 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7236 int API dw_event_close(HEV *eve)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7237 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7238 if(eve)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7239 return CloseHandle(*eve);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7240 return FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7241 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7242
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7243 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7244 * Creates a new thread with a starting point of func.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7245 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7246 * func: Function which will be run in the new thread.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7247 * data: Parameter(s) passed to the function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7248 * stack: Stack size of new thread (OS/2 and Windows only).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7249 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7250 DWTID API dw_thread_new(void *func, void *data, int stack)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7251 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7252 #if defined(__CYGWIN__)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7253 return 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7254 #else
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7255 return (DWTID)_beginthread((void(*)(void *))func, stack, data);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7256 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7257 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7258
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7259 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7260 * Ends execution of current thread immediately.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7261 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7262 void API dw_thread_end(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7263 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7264 #if !defined(__CYGWIN__)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7265 _endthread();
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7266 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7267 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7268
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7269 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7270 * Returns the current thread's ID.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7271 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7272 DWTID API dw_thread_id(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7273 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7274 #if defined(__CYGWIN__)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7275 return 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7276 #else
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7277 return (DWTID)GetCurrentThreadId();
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7278 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7279 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7280
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7281 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7282 * Cleanly terminates a DW session, should be signal handler safe.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7283 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7284 * exitcode: Exit code reported to the operating system.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7285 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7286 void API dw_exit(int exitcode)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7287 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7288 exit(exitcode);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7289 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7290
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7291 /*
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7292 * Creates a splitbar window (widget) with given parameters.
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7293 * Parameters:
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
7294 * type: Value can be DW_VERT or DW_HORZ.
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7295 * topleft: Handle to the window to be top or left.
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7296 * bottomright: Handle to the window to be bottom or right.
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7297 * Returns:
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7298 * A handle to a splitbar window or NULL on failure.
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7299 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7300 HWND API dw_splitbar_new(int type, HWND topleft, HWND bottomright, unsigned long id)
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7301 {
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7302 HWND tmp = CreateWindow(SplitbarClassName,
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7303 "",
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7304 WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN,
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7305 0,0,2000,1000,
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7306 DW_HWND_OBJECT,
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 118
diff changeset
7307 (HMENU)id,
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7308 DWInstance,
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7309 NULL);
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7310
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7311 if(tmp)
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7312 {
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
7313 HWND tmpbox = dw_box_new(DW_VERT, 0);
124
edf615d8266e Use float instead of int for percent on Windows. And a minor safety check
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7314 float *percent = (float *)malloc(sizeof(float));
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7315
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7316 dw_box_pack_start(tmpbox, topleft, 1, 1, TRUE, TRUE, 0);
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7317 SetParent(tmpbox, tmp);
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7318 dw_window_set_data(tmp, "_dw_topleft", (void *)tmpbox);
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7319
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
7320 tmpbox = dw_box_new(DW_VERT, 0);
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7321 dw_box_pack_start(tmpbox, bottomright, 1, 1, TRUE, TRUE, 0);
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7322 SetParent(tmpbox, tmp);
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7323 dw_window_set_data(tmp, "_dw_bottomright", (void *)tmpbox);
124
edf615d8266e Use float instead of int for percent on Windows. And a minor safety check
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7324 *percent = 50.0;
edf615d8266e Use float instead of int for percent on Windows. And a minor safety check
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7325 dw_window_set_data(tmp, "_dw_percent", (void *)percent);
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7326 dw_window_set_data(tmp, "_dw_type", (void *)type);
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7327 }
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7328 return tmp;
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7329 }
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7330
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7331 /*
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7332 * Sets the position of a splitbar (pecentage).
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7333 * Parameters:
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7334 * handle: The handle to the splitbar returned by dw_splitbar_new().
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7335 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7336 void API dw_splitbar_set(HWND handle, float percent)
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7337 {
124
edf615d8266e Use float instead of int for percent on Windows. And a minor safety check
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7338 float *mypercent = (float *)dw_window_get_data(handle, "_dw_percent");
129
e47c52b37cdd Code cleanup and OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 127
diff changeset
7339 int type = (int)dw_window_get_data(handle, "_dw_type");
e47c52b37cdd Code cleanup and OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 127
diff changeset
7340 unsigned long width, height;
124
edf615d8266e Use float instead of int for percent on Windows. And a minor safety check
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7341
edf615d8266e Use float instead of int for percent on Windows. And a minor safety check
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7342 if(mypercent)
edf615d8266e Use float instead of int for percent on Windows. And a minor safety check
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7343 *mypercent = percent;
129
e47c52b37cdd Code cleanup and OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 127
diff changeset
7344
e47c52b37cdd Code cleanup and OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 127
diff changeset
7345 dw_window_get_pos_size(handle, NULL, NULL, &width, &height);
e47c52b37cdd Code cleanup and OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 127
diff changeset
7346
e47c52b37cdd Code cleanup and OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 127
diff changeset
7347 _handle_splitbar_resize(handle, percent, type, width, height);
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7348 }
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7349
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7350 /*
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7351 * Gets the position of a splitbar (pecentage).
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7352 * Parameters:
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7353 * handle: The handle to the splitbar returned by dw_splitbar_new().
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7354 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7355 float API dw_splitbar_get(HWND handle)
124
edf615d8266e Use float instead of int for percent on Windows. And a minor safety check
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7356 {
edf615d8266e Use float instead of int for percent on Windows. And a minor safety check
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7357 float *percent = (float *)dw_window_get_data(handle, "_dw_percent");
edf615d8266e Use float instead of int for percent on Windows. And a minor safety check
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7358
edf615d8266e Use float instead of int for percent on Windows. And a minor safety check
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7359 if(percent)
edf615d8266e Use float instead of int for percent on Windows. And a minor safety check
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7360 return *percent;
edf615d8266e Use float instead of int for percent on Windows. And a minor safety check
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7361 return 0.0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7362 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7363
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7364 /*
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7365 * Pack windows (widgets) into a box from the end (or bottom).
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7366 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7367 * box: Window handle of the box to be packed into.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7368 * item: Window handle of the item to be back.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7369 * width: Width in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7370 * height: Height in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7371 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7372 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7373 * pad: Number of pixels of padding around the item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7374 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7375 void API dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7376 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7377 Box *thisbox;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7378
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7379 thisbox = (Box *)GetWindowLong(box, GWL_USERDATA);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7380 if(thisbox)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7381 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7382 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7383 Item *tmpitem, *thisitem = thisbox->items;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7384 char tmpbuf[100];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7385
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7386 tmpitem = malloc(sizeof(Item)*(thisbox->count+1));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7387
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7388 for(z=0;z<thisbox->count;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7389 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7390 tmpitem[z+1] = thisitem[z];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7391 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7392
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7393 GetClassName(item, tmpbuf, 99);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7394
298
caed245ea8a1 Sanity check, if expand is set width/height can't be zero... force it to 1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 295
diff changeset
7395 if(vsize && !height)
caed245ea8a1 Sanity check, if expand is set width/height can't be zero... force it to 1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 295
diff changeset
7396 height = 1;
caed245ea8a1 Sanity check, if expand is set width/height can't be zero... force it to 1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 295
diff changeset
7397 if(hsize && !width)
caed245ea8a1 Sanity check, if expand is set width/height can't be zero... force it to 1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 295
diff changeset
7398 width = 1;
caed245ea8a1 Sanity check, if expand is set width/height can't be zero... force it to 1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 295
diff changeset
7399
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7400 if(strnicmp(tmpbuf, FRAMECLASSNAME, 2)==0)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7401 tmpitem[0].type = TYPEBOX;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7402 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7403 tmpitem[0].type = TYPEITEM;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7404
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7405 tmpitem[0].hwnd = item;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7406 tmpitem[0].origwidth = tmpitem[0].width = width;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7407 tmpitem[0].origheight = tmpitem[0].height = height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7408 tmpitem[0].pad = pad;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7409 if(hsize)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7410 tmpitem[0].hsize = SIZEEXPAND;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7411 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7412 tmpitem[0].hsize = SIZESTATIC;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7413
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7414 if(vsize)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7415 tmpitem[0].vsize = SIZEEXPAND;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7416 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7417 tmpitem[0].vsize = SIZESTATIC;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7418
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7419 thisbox->items = tmpitem;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7420
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7421 if(thisbox->count)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7422 free(thisitem);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7423
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7424 thisbox->count++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7425
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7426 SetParent(item, box);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7427 if(strncmp(tmpbuf, UPDOWN_CLASS, strlen(UPDOWN_CLASS))==0)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7428 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7429 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(item, GWL_USERDATA);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7430
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7431 if(cinfo)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7432 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7433 SetParent(cinfo->buddy, box);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7434 ShowWindow(cinfo->buddy, SW_SHOW);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7435 SendMessage(item, UDM_SETBUDDY, (WPARAM)cinfo->buddy, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7436 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7437 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7438 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7439 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7440
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7441 /*
34
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
7442 * Sets the default focus item for a window/dialog.
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
7443 * Parameters:
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
7444 * window: Toplevel window or dialog.
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
7445 * defaultitem: Handle to the dialog item to be default.
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
7446 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7447 void API dw_window_default(HWND window, HWND defaultitem)
34
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
7448 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7449 Box *thisbox = (Box *)GetWindowLong(window, GWL_USERDATA);
34
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
7450
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
7451 if(thisbox)
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
7452 thisbox->defaultitem = defaultitem;
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
7453 }
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
7454
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
7455 /*
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
7456 * Sets window to click the default dialog item when an ENTER is pressed.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
7457 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
7458 * window: Window (widget) to look for the ENTER press.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
7459 * next: Window (widget) to move to next (or click)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
7460 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7461 void API dw_window_click_default(HWND window, HWND next)
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
7462 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7463 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(window, GWL_USERDATA);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7464
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7465 if(cinfo)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7466 cinfo->clickdefault = next;
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
7467 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
7468
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
7469 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7470 * Returns some information about the current operating environment.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7471 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7472 * env: Pointer to a DWEnv struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7473 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7474 void API dw_environment_query(DWEnv *env)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7475 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7476 if(!env)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7477 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7478
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7479 /* Get the Windows version. */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7480
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7481 env->MajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7482 env->MinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7483
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7484 /* Get the build number for Windows NT/Windows 2000. */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7485
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7486 env->MinorBuild = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7487
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7488 if (dwVersion < 0x80000000)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7489 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7490 if(env->MajorVersion == 5 && env->MinorVersion == 1)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7491 strcpy(env->osName, "Windows XP");
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7492 else if(env->MajorVersion == 5 && env->MinorVersion == 0)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7493 strcpy(env->osName, "Windows 2000");
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7494 else
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7495 strcpy(env->osName, "Windows NT");
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7496
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7497 env->MajorBuild = (DWORD)(HIWORD(dwVersion));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7498 }
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7499 else
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7500 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7501 strcpy(env->osName, "Windows 95/98/ME");
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7502 env->MajorBuild = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7503 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7504
15
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
7505 strcpy(env->buildDate, __DATE__);
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
7506 strcpy(env->buildTime, __TIME__);
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
7507 env->DWMajorVersion = DW_MAJOR_VERSION;
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
7508 env->DWMinorVersion = DW_MINOR_VERSION;
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
7509 env->DWSubVersion = DW_SUB_VERSION;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7510 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7511
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7512 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7513 * Opens a file dialog and queries user selection.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7514 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7515 * title: Title bar text for dialog.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7516 * defpath: The default path of the open dialog.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7517 * ext: Default file extention.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7518 * flags: DW_FILE_OPEN or DW_FILE_SAVE.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7519 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7520 * NULL on error. A malloced buffer containing
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7521 * the file path on success.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7522 *
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7523 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7524 char * API dw_file_browse(char *title, char *defpath, char *ext, int flags)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7525 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7526 OPENFILENAME of;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7527 char filenamebuf[1001] = "";
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7528 int rc;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7529
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7530 if(ext)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7531 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7532 strcpy(filenamebuf, "*.");
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7533 strcat(filenamebuf, ext);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7534 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7535
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7536 memset(&of, 0, sizeof(OPENFILENAME));
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7537
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7538 of.lStructSize = sizeof(OPENFILENAME);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7539 of.hwndOwner = HWND_DESKTOP;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7540 of.hInstance = DWInstance;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7541 of.lpstrInitialDir = defpath;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7542 of.lpstrTitle = title;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7543 of.lpstrFile = filenamebuf;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7544 of.nMaxFile = 1000;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7545 of.lpstrDefExt = ext;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7546 of.Flags = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7547
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7548 if(flags & DW_FILE_SAVE)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7549 rc = GetSaveFileName(&of);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7550 else
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7551 rc = GetOpenFileName(&of);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7552
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7553 if(rc)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7554 return strdup(of.lpstrFile);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7555
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7556 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7557 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7558
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7559 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7560 * Execute and external program in a seperate session.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7561 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7562 * program: Program name with optional path.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7563 * type: Either DW_EXEC_CON or DW_EXEC_GUI.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7564 * params: An array of pointers to string arguements.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7565 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7566 * -1 on error.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7567 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7568 int API dw_exec(char *program, int type, char **params)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7569 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7570 char **newparams;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7571 int retcode, count = 0, z;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7572
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7573 while(params[count])
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7574 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7575 count++;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7576 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7577
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7578 newparams = (char **)malloc(sizeof(char *) * (count+1));
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7579
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7580 for(z=0;z<count;z++)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7581 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7582 newparams[z] = malloc(strlen(params[z])+3);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7583 strcpy(newparams[z], "\"");
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7584 strcat(newparams[z], params[z]);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7585 strcat(newparams[z], "\"");
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7586 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7587 newparams[count] = NULL;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7588
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7589 retcode = spawnvp(P_NOWAIT, program, newparams);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7590
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7591 for(z=0;z<count;z++)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7592 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7593 free(newparams[z]);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7594 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7595 free(newparams);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7596
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7597 return retcode;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7598 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7599
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7600 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7601 * Loads a web browser pointed at the given URL.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7602 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7603 * url: Uniform resource locator.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7604 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7605 int API dw_browse(char *url)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7606 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7607 char *browseurl = url;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7608 int retcode;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7609
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7610 if(strlen(url) > 7 && strncmp(url, "file://", 7) == 0)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7611 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7612 int len, z;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7613
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7614 browseurl = &url[7];
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7615 len = strlen(browseurl);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7616
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7617 for(z=0;z<len;z++)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7618 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7619 if(browseurl[z] == '|')
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7620 browseurl[z] = ':';
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7621 if(browseurl[z] == '/')
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7622 browseurl[z] = '\\';
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7623 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7624 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7625
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7626 retcode = (int)ShellExecute(NULL, "open", browseurl, NULL, NULL, SW_SHOWNORMAL);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7627 if(retcode<33 && retcode != 2)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7628 return -1;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7629 return 1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7630 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7631
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7632 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7633 * Returns a pointer to a static buffer which containes the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7634 * current user directory. Or the root directory (C:\ on
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7635 * OS/2 and Windows).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7636 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7637 char * API dw_user_dir(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7638 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7639 static char _user_dir[1024] = "";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7640
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7641 if(!_user_dir[0])
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7642 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7643 /* Figure out how to do this the "Windows way" */
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7644 char *home = getenv("HOME");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7645
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7646 if(home)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7647 strcpy(_user_dir, home);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7648 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7649 strcpy(_user_dir, "C:\\");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7650 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7651 return _user_dir;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7652 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7653
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7654 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7655 * Call a function from the window (widget)'s context.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7656 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7657 * handle: Window handle of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7658 * function: Function pointer to be called.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7659 * data: Pointer to the data to be passed to the function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7660 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7661 void API dw_window_function(HWND handle, void *function, void *data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7662 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7663 SendMessage(handle, WM_USER, (WPARAM)function, (LPARAM)data);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7664 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7665
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7666 /* Functions for managing the user data lists that are associated with
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7667 * a given window handle. Used in dw_window_set_data() and
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7668 * dw_window_get_data().
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7669 */
180
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
7670 UserData *_find_userdata(UserData **root, char *varname)
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7671 {
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7672 UserData *tmp = *root;
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7673
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7674 while(tmp)
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7675 {
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7676 if(stricmp(tmp->varname, varname) == 0)
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7677 return tmp;
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7678 tmp = tmp->next;
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7679 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7680 return NULL;
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7681 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7682
180
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
7683 int _new_userdata(UserData **root, char *varname, void *data)
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
7684 {
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
7685 UserData *new = _find_userdata(root, varname);
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7686
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7687 if(new)
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7688 {
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7689 new->data = data;
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7690 return TRUE;
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7691 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7692 else
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7693 {
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7694 new = malloc(sizeof(UserData));
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7695 if(new)
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7696 {
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7697 new->varname = strdup(varname);
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7698 new->data = data;
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7699
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7700 new->next = NULL;
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7701
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7702 if (!*root)
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7703 *root = new;
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7704 else
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7705 {
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7706 UserData *prev = NULL, *tmp = *root;
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7707 while(tmp)
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7708 {
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7709 prev = tmp;
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7710 tmp = tmp->next;
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7711 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7712 if(prev)
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7713 prev->next = new;
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7714 else
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7715 *root = new;
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7716 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7717 return TRUE;
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7718 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7719 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7720 return FALSE;
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7721 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7722
180
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
7723 int _remove_userdata(UserData **root, char *varname, int all)
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7724 {
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7725 UserData *prev = NULL, *tmp = *root;
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7726
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7727 while(tmp)
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7728 {
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7729 if(all || stricmp(tmp->varname, varname) == 0)
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7730 {
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7731 if(!prev)
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7732 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 136
diff changeset
7733 *root = tmp->next;
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7734 free(tmp->varname);
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7735 free(tmp);
180
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
7736 if(!all)
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
7737 return 0;
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
7738 tmp = *root;
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7739 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7740 else
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7741 {
180
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
7742 /* If all is true we should
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
7743 * never get here.
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
7744 */
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7745 prev->next = tmp->next;
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7746 free(tmp->varname);
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7747 free(tmp);
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7748 return 0;
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7749 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7750 }
180
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
7751 else
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
7752 {
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
7753 prev = tmp;
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
7754 tmp = tmp->next;
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
7755 }
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7756 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7757 return 0;
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7758 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7759
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7760 /*
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7761 * Add a named user data item to a window handle.
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7762 * Parameters:
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7763 * window: Window handle of signal to be called back.
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7764 * dataname: A string pointer identifying which signal to be hooked.
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7765 * data: User data to be passed to the handler function.
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7766 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7767 void API dw_window_set_data(HWND window, char *dataname, void *data)
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7768 {
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7769 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(window, GWL_USERDATA);
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7770
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7771 if(!cinfo)
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7772 {
180
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
7773 if(!dataname)
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
7774 return;
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
7775
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7776 cinfo = calloc(1, sizeof(ColorInfo));
204
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
7777 cinfo->fore = cinfo->back = -1;
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7778 SetWindowLong(window, GWL_USERDATA, (LONG)cinfo);
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7779 }
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
7780
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7781 if(cinfo)
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7782 {
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7783 if(data)
180
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
7784 _new_userdata(&(cinfo->root), dataname, data);
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7785 else
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7786 {
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7787 if(dataname)
180
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
7788 _remove_userdata(&(cinfo->root), dataname, FALSE);
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7789 else
180
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
7790 _remove_userdata(&(cinfo->root), NULL, TRUE);
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7791 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7792 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7793 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7794
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7795 /*
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7796 * Gets a named user data item to a window handle.
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7797 * Parameters:
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7798 * window: Window handle of signal to be called back.
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7799 * dataname: A string pointer identifying which signal to be hooked.
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7800 * data: User data to be passed to the handler function.
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7801 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7802 void * API dw_window_get_data(HWND window, char *dataname)
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7803 {
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7804 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(window, GWL_USERDATA);
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7805
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7806 if(cinfo && cinfo->root && dataname)
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7807 {
180
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
7808 UserData *ud = _find_userdata(&(cinfo->root), dataname);
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7809 if(ud)
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7810 return ud->data;
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7811 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7812 return NULL;
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7813 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
7814
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7815 /*
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7816 * Add a callback to a timer event.
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7817 * Parameters:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7818 * interval: Milliseconds to delay between calls.
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7819 * sigfunc: The pointer to the function to be used as the callback.
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7820 * data: User data to be passed to the handler function.
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7821 * Returns:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7822 * Timer ID for use with dw_timer_disconnect(), 0 on error.
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7823 */
200
446dd8cea477 Removed window parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 197
diff changeset
7824 int API dw_timer_connect(int interval, void *sigfunc, void *data)
446dd8cea477 Removed window parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 197
diff changeset
7825 {
446dd8cea477 Removed window parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 197
diff changeset
7826 if(sigfunc)
446dd8cea477 Removed window parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 197
diff changeset
7827 {
446dd8cea477 Removed window parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 197
diff changeset
7828 int timerid = SetTimer(NULL, 0, interval, NULL);
446dd8cea477 Removed window parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 197
diff changeset
7829
446dd8cea477 Removed window parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 197
diff changeset
7830 if(timerid)
446dd8cea477 Removed window parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 197
diff changeset
7831 {
446dd8cea477 Removed window parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 197
diff changeset
7832 _new_signal(WM_TIMER, NULL, timerid, sigfunc, data);
446dd8cea477 Removed window parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 197
diff changeset
7833 return timerid;
446dd8cea477 Removed window parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 197
diff changeset
7834 }
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7835 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7836 return 0;
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7837 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7838
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7839 /*
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7840 * Removes timer callback.
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7841 * Parameters:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7842 * id: Timer ID returned by dw_timer_connect().
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7843 */
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7844 void API dw_timer_disconnect(int id)
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7845 {
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7846 SignalHandler *prev = NULL, *tmp = Root;
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7847
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7848 /* 0 is an invalid timer ID */
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7849 if(!id)
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7850 return;
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7851
200
446dd8cea477 Removed window parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 197
diff changeset
7852 KillTimer(NULL, id);
446dd8cea477 Removed window parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 197
diff changeset
7853
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7854 while(tmp)
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7855 {
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7856 if(tmp->id == id)
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7857 {
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7858 if(prev)
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7859 {
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7860 prev->next = tmp->next;
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7861 free(tmp);
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7862 tmp = prev->next;
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7863 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7864 else
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7865 {
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7866 Root = tmp->next;
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7867 free(tmp);
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7868 tmp = Root;
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7869 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7870 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7871 else
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7872 {
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7873 prev = tmp;
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7874 tmp = tmp->next;
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7875 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7876 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7877 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7878
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7879 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7880 * Add a callback to a window event.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7881 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7882 * window: Window handle of signal to be called back.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7883 * signame: A string pointer identifying which signal to be hooked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7884 * sigfunc: The pointer to the function to be used as the callback.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7885 * data: User data to be passed to the handler function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7886 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7887 void API dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7888 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7889 ULONG message = 0L;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7890
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7891 if(window && signame && sigfunc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7892 {
307
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 303
diff changeset
7893 if(stricmp(signame, DW_SIGNAL_SET_FOCUS) == 0)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7894 window = _normalize_handle(window);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7895
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7896 if((message = _findsigmessage(signame)) != 0)
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
7897 _new_signal(message, window, 0, sigfunc, data);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7898 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7899 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7900
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7901 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7902 * Removes callbacks for a given window with given name.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7903 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7904 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7905 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7906 void API dw_signal_disconnect_by_name(HWND window, char *signame)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7907 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7908 SignalHandler *prev = NULL, *tmp = Root;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7909 ULONG message;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7910
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7911 if(!window || !signame || (message = _findsigmessage(signame)) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7912 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7913
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7914 while(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7915 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7916 if(tmp->window == window && tmp->message == message)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7917 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7918 if(prev)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7919 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7920 prev->next = tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7921 free(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7922 tmp = prev->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7923 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7924 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7925 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7926 Root = tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7927 free(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7928 tmp = Root;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7929 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7930 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7931 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7932 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7933 prev = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7934 tmp = tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7935 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7936 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7937 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7938
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7939 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7940 * Removes all callbacks for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7941 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7942 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7943 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7944 void API dw_signal_disconnect_by_window(HWND window)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7945 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7946 SignalHandler *prev = NULL, *tmp = Root;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7947
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7948 while(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7949 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7950 if(tmp->window == window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7951 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7952 if(prev)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7953 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7954 prev->next = tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7955 free(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7956 tmp = prev->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7957 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7958 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7959 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7960 Root = tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7961 free(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7962 tmp = Root;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7963 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7964 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7965 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7966 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7967 prev = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7968 tmp = tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7969 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7970 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7971 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7972
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7973 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7974 * Removes all callbacks for a given window with specified data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7975 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7976 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7977 * data: Pointer to the data to be compared against.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7978 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7979 void API dw_signal_disconnect_by_data(HWND window, void *data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7980 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7981 SignalHandler *prev = NULL, *tmp = Root;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7982
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7983 while(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7984 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7985 if(tmp->window == window && tmp->data == data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7986 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7987 if(prev)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7988 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7989 prev->next = tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7990 free(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7991 tmp = prev->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7992 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7993 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7994 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7995 Root = tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7996 free(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7997 tmp = Root;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7998 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7999 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8000 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8001 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8002 prev = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8003 tmp = tmp->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8004 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8005 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8006 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8007