Mercurial > dwindows
annotate gtk/dw.c @ 438:fac2afe7bda3
Only throw up the messagebox when expand and size are both 0 and the item
being packed is not a box. Also moved some private OS/2 prototypes out
of the header.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 29 May 2003 09:18:54 +0000 |
parents | f977c80a1dfa |
children | 7c8bd3bc6c27 |
rev | line source |
---|---|
3 | 1 /* |
2 * Dynamic Windows: | |
3 * A GTK like implementation of the PM GUI | |
4 * GTK forwarder module for portabilty. | |
5 * | |
283
54aafc134652
BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
282
diff
changeset
|
6 * (C) 2000-2003 Brian Smith <dbsoft@technologist.com> |
369
39983df2b93d
Updated the license information, and copyrights. Code to do background
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
364
diff
changeset
|
7 * (C) 2003 Mark Hessling <m.hessling@qut.edu.au> |
3 | 8 * |
9 */ | |
10 #include "dw.h" | |
11 #include <string.h> | |
12 #include <stdlib.h> | |
13 #include <sys/utsname.h> | |
14 #include <stdarg.h> | |
15 #include <stdio.h> | |
16 #include <unistd.h> | |
17 #include <errno.h> | |
18 #include <sys/time.h> | |
19 #include "config.h" | |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
20 #include <gdk/gdkkeysyms.h> |
3 | 21 #ifdef USE_IMLIB |
22 #include <gdk_imlib.h> | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
23 #endif |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
24 #if GTK_MAJOR_VERSION > 1 |
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
|
25 #include <gdk-pixbuf/gdk-pixbuf.h> |
3 | 26 #endif |
27 | |
401
306ce9765a61
Fixes for new message box code. Also incorporated a fix from dw_window_set
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
399
diff
changeset
|
28 #include "gtk/messagebox_error.xpm" |
306ce9765a61
Fixes for new message box code. Also incorporated a fix from dw_window_set
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
399
diff
changeset
|
29 #include "gtk/messagebox_warning.xpm" |
306ce9765a61
Fixes for new message box code. Also incorporated a fix from dw_window_set
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
399
diff
changeset
|
30 #include "gtk/messagebox_information.xpm" |
306ce9765a61
Fixes for new message box code. Also incorporated a fix from dw_window_set
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
399
diff
changeset
|
31 #include "gtk/messagebox_question.xpm" |
399
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
32 |
3 | 33 /* These are used for resource management */ |
34 #if defined(DW_RESOURCES) && !defined(BUILD_DLL) | |
35 extern DWResources _resources; | |
36 #endif | |
37 | |
38 GdkColor _colors[] = | |
39 { | |
40 { 0, 0x0000, 0x0000, 0x0000 }, /* 0 black */ | |
41 { 0, 0xbbbb, 0x0000, 0x0000 }, /* 1 red */ | |
42 { 0, 0x0000, 0xbbbb, 0x0000 }, /* 2 green */ | |
43 { 0, 0xaaaa, 0xaaaa, 0x0000 }, /* 3 yellow */ | |
44 { 0, 0x0000, 0x0000, 0xcccc }, /* 4 blue */ | |
45 { 0, 0xbbbb, 0x0000, 0xbbbb }, /* 5 magenta */ | |
46 { 0, 0x0000, 0xbbbb, 0xbbbb }, /* 6 cyan */ | |
142
9560efb7bea2
Make DW_CLR_PALEGRAY a bit lighter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
141
diff
changeset
|
47 { 0, 0xbbbb, 0xbbbb, 0xbbbb }, /* 7 white */ |
3 | 48 { 0, 0x7777, 0x7777, 0x7777 }, /* 8 grey */ |
49 { 0, 0xffff, 0x0000, 0x0000 }, /* 9 bright red */ | |
50 { 0, 0x0000, 0xffff, 0x0000 }, /* 10 bright green */ | |
51 { 0, 0xeeee, 0xeeee, 0x0000 }, /* 11 bright yellow */ | |
52 { 0, 0x0000, 0x0000, 0xffff }, /* 12 bright blue */ | |
53 { 0, 0xffff, 0x0000, 0xffff }, /* 13 bright magenta */ | |
54 { 0, 0x0000, 0xeeee, 0xeeee }, /* 14 bright cyan */ | |
55 { 0, 0xffff, 0xffff, 0xffff }, /* 15 bright white */ | |
56 }; | |
57 | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
58 #define DW_THREAD_LIMIT 50 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
59 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
60 DWTID _dw_thread_list[DW_THREAD_LIMIT]; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
61 GdkColor _foreground[DW_THREAD_LIMIT]; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
62 GdkColor _background[DW_THREAD_LIMIT]; |
373
d04b0699fc28
Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
372
diff
changeset
|
63 int _transparent[DW_THREAD_LIMIT]; |
3 | 64 |
93
98cce029a611
Changed handling of menu item click events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
92
diff
changeset
|
65 GtkWidget *last_window = NULL, *popup = NULL; |
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
|
66 |
359
9ddcbbaebd50
Fix warning caused by removal of obsolete code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
358
diff
changeset
|
67 static int _dw_file_active = 0, _dw_ignore_click = 0; |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
68 static pthread_t _dw_thread = (pthread_t)-1; |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
69 static int _dw_mutex_locked[DW_THREAD_LIMIT]; |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
70 /* Use default border size for the default enlightenment theme */ |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
71 static int _dw_border_width = 12, _dw_border_height = 28; |
3 | 72 |
75
c629838d9805
Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
72
diff
changeset
|
73 #define DW_MUTEX_LOCK { int index = _find_thread_index(dw_thread_id()); if(pthread_self() != _dw_thread && _dw_mutex_locked[index] == FALSE) { gdk_threads_enter(); _dw_mutex_locked[index] = TRUE; _locked_by_me = TRUE; } } |
c629838d9805
Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
72
diff
changeset
|
74 #define DW_MUTEX_UNLOCK { if(pthread_self() != _dw_thread && _locked_by_me == TRUE) { gdk_threads_leave(); _dw_mutex_locked[_find_thread_index(dw_thread_id())] = FALSE; _locked_by_me = FALSE; } } |
3 | 75 |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
76 #define DEFAULT_SIZE_WIDTH 12 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
77 #define DEFAULT_SIZE_HEIGHT 6 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
78 #define DEFAULT_TITLEBAR_HEIGHT 22 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
79 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
80 static GdkColormap *_dw_cmap = NULL; |
3 | 81 |
82 /* Signal forwarder prototypes */ | |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
83 static gint _button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data); |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
84 static gint _button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer data); |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
85 static gint _motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gpointer data); |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
86 static gint _delete_event(GtkWidget *widget, GdkEvent *event, gpointer data); |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
87 static gint _key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data); |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
88 static gint _generic_event(GtkWidget *widget, gpointer data); |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
89 static gint _configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data); |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
90 static gint _activate_event(GtkWidget *widget, gpointer data); |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
91 static gint _container_select_event(GtkWidget *widget, GdkEventButton *event, gpointer data); |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
92 static gint _container_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data); |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
93 static gint _item_select_event(GtkWidget *widget, GtkWidget *child, gpointer data); |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
94 static gint _expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data); |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
95 static gint _set_focus_event(GtkWindow *window, GtkWidget *widget, gpointer data); |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
96 static gint _tree_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data); |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
97 static gint _value_changed_event(GtkAdjustment *adjustment, gpointer user_data); |
140
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
98 #if GTK_MAJOR_VERSION > 1 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
99 static gint _tree_select_event(GtkTreeSelection *sel, gpointer data); |
140
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
100 #else |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
101 static gint _tree_select_event(GtkTree *tree, GtkWidget *child, gpointer data); |
140
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
102 #endif |
331
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
103 static gint _switch_page_event(GtkNotebook *notebook, GtkNotebookPage *page, guint page_num, gpointer user_data); |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
104 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
105 typedef struct |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
106 { |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
107 GdkPixmap *pixmap; |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
108 GdkBitmap *mask; |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
109 int used; |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
110 unsigned long width, height; |
316
a07e08f708d6
Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
312
diff
changeset
|
111 #if GTK_MAJOR_VERSION > 1 |
a07e08f708d6
Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
312
diff
changeset
|
112 GdkPixbuf *pixbuf; |
a07e08f708d6
Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
312
diff
changeset
|
113 #endif |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
114 } DWPrivatePixmap; |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
115 |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
116 static DWPrivatePixmap *_PixmapArray = NULL; |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
117 static int _PixmapCount = 0; |
3 | 118 |
119 typedef struct | |
120 { | |
121 void *func; | |
122 char name[30]; | |
123 | |
124 } SignalList; | |
125 | |
126 typedef struct | |
127 { | |
128 HWND window; | |
129 void *func; | |
130 gpointer data; | |
409
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
131 gint cid; |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
132 void *intfunc; |
3 | 133 |
134 } SignalHandler; | |
135 | |
331
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
136 #define SIGNALMAX 17 |
3 | 137 |
138 /* A list of signal forwarders, to account for paramater differences. */ | |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
139 static SignalList SignalTranslate[SIGNALMAX] = { |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
140 { _configure_event, DW_SIGNAL_CONFIGURE }, |
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
141 { _key_press_event, DW_SIGNAL_KEY_PRESS }, |
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
142 { _button_press_event, DW_SIGNAL_BUTTON_PRESS }, |
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
143 { _button_release_event, DW_SIGNAL_BUTTON_RELEASE }, |
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
144 { _motion_notify_event, DW_SIGNAL_MOTION_NOTIFY }, |
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
145 { _delete_event, DW_SIGNAL_DELETE }, |
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
146 { _expose_event, DW_SIGNAL_EXPOSE }, |
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
147 { _activate_event, "activate" }, |
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
148 { _generic_event, DW_SIGNAL_CLICKED }, |
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
149 { _container_select_event, DW_SIGNAL_ITEM_ENTER }, |
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
150 { _container_context_event, DW_SIGNAL_ITEM_CONTEXT }, |
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
151 { _tree_context_event, "tree-context" }, |
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
152 { _item_select_event, DW_SIGNAL_LIST_SELECT }, |
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
153 { _tree_select_event, DW_SIGNAL_ITEM_SELECT }, |
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
154 { _set_focus_event, DW_SIGNAL_SET_FOCUS }, |
331
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
155 { _value_changed_event, DW_SIGNAL_VALUE_CHANGED }, |
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
156 { _switch_page_event, DW_SIGNAL_SWITCH_PAGE } |
3 | 157 }; |
158 | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
159 /* Alignment flags */ |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
160 #define DW_CENTER 0.5f |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
161 #define DW_LEFT 0.0f |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
162 #define DW_RIGHT 1.0f |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
163 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
164 static void _dw_msleep(long period) |
237
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
165 { |
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
166 #ifdef __sun__ |
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
167 /* usleep() isn't threadsafe on Solaris */ |
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
168 struct timespec req; |
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
169 |
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
170 req.tv_sec = 0; |
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
171 req.tv_nsec = period * 10000000; |
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
172 |
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
173 nanosleep(&req, NULL); |
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
174 #else |
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
175 usleep(period * 1000); |
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
176 #endif |
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
177 } |
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
178 |
3 | 179 /* Finds the translation function for a given signal name */ |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
180 static void *_findsigfunc(char *signame) |
3 | 181 { |
182 int z; | |
183 | |
184 for(z=0;z<SIGNALMAX;z++) | |
185 { | |
186 if(strcasecmp(signame, SignalTranslate[z].name) == 0) | |
187 return SignalTranslate[z].func; | |
188 } | |
189 return NULL; | |
190 } | |
191 | |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
192 static SignalHandler _get_signal_handler(GtkWidget *widget, gpointer data) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
193 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
194 int counter = (int)data; |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
195 SignalHandler sh; |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
196 char text[100]; |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
197 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
198 sprintf(text, "_dw_sigwindow%d", counter); |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
199 sh.window = (HWND)gtk_object_get_data(GTK_OBJECT(widget), text); |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
200 sprintf(text, "_dw_sigfunc%d", counter); |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
201 sh.func = (void *)gtk_object_get_data(GTK_OBJECT(widget), text); |
409
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
202 sprintf(text, "_dw_intfunc%d", counter); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
203 sh.intfunc = (void *)gtk_object_get_data(GTK_OBJECT(widget), text); |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
204 sprintf(text, "_dw_sigdata%d", counter); |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
205 sh.data = gtk_object_get_data(GTK_OBJECT(widget), text); |
409
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
206 sprintf(text, "_dw_sigcid%d", counter); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
207 sh.cid = (gint)gtk_object_get_data(GTK_OBJECT(widget), text); |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
208 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
209 return sh; |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
210 } |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
211 |
409
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
212 static void _remove_signal_handler(GtkWidget *widget, int counter) |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
213 { |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
214 char text[100]; |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
215 gint cid; |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
216 |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
217 sprintf(text, "_dw_sigcid%d", counter); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
218 cid = (gint)gtk_object_get_data(GTK_OBJECT(widget), text); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
219 gtk_signal_disconnect(GTK_OBJECT(widget), cid); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
220 gtk_object_set_data(GTK_OBJECT(widget), text, NULL); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
221 sprintf(text, "_dw_sigwindow%d", counter); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
222 gtk_object_set_data(GTK_OBJECT(widget), text, NULL); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
223 sprintf(text, "_dw_sigfunc%d", counter); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
224 gtk_object_set_data(GTK_OBJECT(widget), text, NULL); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
225 sprintf(text, "_dw_intfunc%d", counter); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
226 gtk_object_set_data(GTK_OBJECT(widget), text, NULL); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
227 sprintf(text, "_dw_sigdata%d", counter); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
228 gtk_object_set_data(GTK_OBJECT(widget), text, NULL); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
229 } |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
230 |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
231 static int _set_signal_handler(GtkWidget *widget, HWND window, void *func, gpointer data, void *intfunc) |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
232 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
233 int counter = (int)gtk_object_get_data(GTK_OBJECT(widget), "_dw_sigcounter"); |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
234 char text[100]; |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
235 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
236 sprintf(text, "_dw_sigwindow%d", counter); |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
237 gtk_object_set_data(GTK_OBJECT(widget), text, (gpointer)window); |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
238 sprintf(text, "_dw_sigfunc%d", counter); |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
239 gtk_object_set_data(GTK_OBJECT(widget), text, (gpointer)func); |
409
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
240 sprintf(text, "_dw_intfunc%d", counter); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
241 gtk_object_set_data(GTK_OBJECT(widget), text, (gpointer)intfunc); |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
242 sprintf(text, "_dw_sigdata%d", counter); |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
243 gtk_object_set_data(GTK_OBJECT(widget), text, (gpointer)data); |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
244 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
245 counter++; |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
246 gtk_object_set_data(GTK_OBJECT(widget), "_dw_sigcounter", (gpointer)counter); |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
247 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
248 return counter - 1; |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
249 } |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
250 |
409
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
251 static void _set_signal_handler_id(GtkWidget *widget, int counter, gint cid) |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
252 { |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
253 char text[100]; |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
254 |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
255 sprintf(text, "_dw_sigcid%d", counter); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
256 gtk_object_set_data(GTK_OBJECT(widget), text, (gpointer)cid); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
257 } |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
258 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
259 static gint _set_focus_event(GtkWindow *window, GtkWidget *widget, gpointer data) |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
260 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
261 SignalHandler work = _get_signal_handler((GtkWidget *)window, data); |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
262 int retval = FALSE; |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
263 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
264 if(work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
265 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
266 int (*setfocusfunc)(HWND, void *) = work.func; |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
267 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
268 retval = setfocusfunc(work.window, work.data); |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
269 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
270 return retval; |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
271 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
272 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
273 static gint _button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data) |
3 | 274 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
275 SignalHandler work = _get_signal_handler(widget, data); |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
276 int retval = FALSE; |
3 | 277 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
278 if(work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
279 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
280 int (*buttonfunc)(HWND, int, int, int, void *) = work.func; |
3 | 281 int mybutton = event->button; |
282 | |
283 if(event->button == 3) | |
284 mybutton = 2; | |
285 else if(event->button == 2) | |
286 mybutton = 3; | |
287 | |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
288 retval = buttonfunc(work.window, event->x, event->y, mybutton, work.data); |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
289 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
290 return retval; |
3 | 291 } |
292 | |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
293 static gint _button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer data) |
3 | 294 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
295 SignalHandler work = _get_signal_handler(widget, data); |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
296 int retval = FALSE; |
3 | 297 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
298 if(work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
299 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
300 int (*buttonfunc)(HWND, int, int, int, void *) = work.func; |
3 | 301 int mybutton = event->button; |
302 | |
303 if(event->button == 3) | |
304 mybutton = 2; | |
305 else if(event->button == 2) | |
306 mybutton = 3; | |
307 | |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
308 retval = buttonfunc(work.window, event->x, event->y, mybutton, work.data); |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
309 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
310 return retval; |
3 | 311 } |
312 | |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
313 static gint _motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gpointer data) |
3 | 314 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
315 SignalHandler work = _get_signal_handler(widget, data); |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
316 int retval = FALSE; |
3 | 317 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
318 if(work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
319 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
320 int (*motionfunc)(HWND, int, int, int, void *) = work.func; |
3 | 321 int keys = 0, x, y; |
322 GdkModifierType state; | |
323 | |
324 if (event->is_hint) | |
325 gdk_window_get_pointer (event->window, &x, &y, &state); | |
326 else | |
327 { | |
328 x = event->x; | |
329 y = event->y; | |
330 state = event->state; | |
331 } | |
332 | |
333 if (state & GDK_BUTTON1_MASK) | |
334 keys = DW_BUTTON1_MASK; | |
335 if (state & GDK_BUTTON3_MASK) | |
336 keys |= DW_BUTTON2_MASK; | |
337 if (state & GDK_BUTTON2_MASK) | |
338 keys |= DW_BUTTON3_MASK; | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
339 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
340 retval = motionfunc(work.window, x, y, keys, work.data); |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
341 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
342 return retval; |
3 | 343 } |
344 | |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
345 static gint _delete_event(GtkWidget *widget, GdkEvent *event, gpointer data) |
3 | 346 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
347 SignalHandler work = _get_signal_handler(widget, data); |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
348 int retval = FALSE; |
3 | 349 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
350 if(work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
351 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
352 int (*closefunc)(HWND, void *) = work.func; |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
353 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
354 retval = closefunc(work.window, work.data); |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
355 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
356 return retval; |
3 | 357 } |
358 | |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
359 static gint _key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data) |
3 | 360 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
361 SignalHandler work = _get_signal_handler(widget, data); |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
362 int retval = FALSE; |
3 | 363 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
364 if(work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
365 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
366 int (*keypressfunc)(HWND, char, int, int, void *) = work.func; |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
367 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
368 retval = keypressfunc(work.window, *event->string, event->keyval, |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
369 event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_MOD1_MASK), work.data); |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
370 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
371 return retval; |
3 | 372 } |
373 | |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
374 static gint _generic_event(GtkWidget *widget, gpointer data) |
3 | 375 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
376 SignalHandler work = _get_signal_handler(widget, data); |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
377 int retval = FALSE; |
3 | 378 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
379 if(work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
380 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
381 int (*genericfunc)(HWND, void *) = work.func; |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
382 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
383 retval = genericfunc(work.window, work.data); |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
384 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
385 return retval; |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
386 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
387 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
388 static gint _activate_event(GtkWidget *widget, gpointer data) |
3 | 389 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
390 SignalHandler work = _get_signal_handler(widget, data); |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
391 int retval = FALSE; |
3 | 392 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
393 if(work.window && !_dw_ignore_click) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
394 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
395 int (*activatefunc)(HWND, void *) = work.func; |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
396 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
397 retval = activatefunc(popup ? popup : work.window, work.data); |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
398 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
399 return retval; |
3 | 400 } |
401 | |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
402 static gint _configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data) |
3 | 403 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
404 SignalHandler work = _get_signal_handler(widget, data); |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
405 int retval = FALSE; |
3 | 406 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
407 if(work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
408 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
409 int (*sizefunc)(HWND, int, int, void *) = work.func; |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
410 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
411 retval = sizefunc(work.window, event->width, event->height, work.data); |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
412 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
413 return retval; |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
414 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
415 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
416 static gint _expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data) |
3 | 417 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
418 SignalHandler work = _get_signal_handler(widget, data); |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
419 int retval = FALSE; |
3 | 420 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
421 if(work.window) |
3 | 422 { |
423 DWExpose exp; | |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
424 int (*exposefunc)(HWND, DWExpose *, void *) = work.func; |
3 | 425 |
426 exp.x = event->area.x; | |
427 exp.y = event->area.y; | |
428 exp.width = event->area.width; | |
429 exp.height = event->area.height; | |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
430 retval = exposefunc(work.window, &exp, work.data); |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
431 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
432 return retval; |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
433 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
434 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
435 static gint _item_select_event(GtkWidget *widget, GtkWidget *child, gpointer data) |
3 | 436 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
437 SignalHandler work = _get_signal_handler(widget, data); |
39
3aa9ef0b3996
Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
37
diff
changeset
|
438 static int _dw_recursing = 0; |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
439 int retval = FALSE; |
39
3aa9ef0b3996
Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
37
diff
changeset
|
440 |
3aa9ef0b3996
Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
37
diff
changeset
|
441 if(_dw_recursing) |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
442 return FALSE; |
3 | 443 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
444 if(work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
445 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
446 int (*selectfunc)(HWND, int, void *) = work.func; |
3 | 447 GList *list; |
448 int item = 0; | |
449 | |
39
3aa9ef0b3996
Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
37
diff
changeset
|
450 _dw_recursing = 1; |
3aa9ef0b3996
Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
37
diff
changeset
|
451 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
452 if(GTK_IS_COMBO(work.window)) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
453 list = GTK_LIST(GTK_COMBO(work.window)->list)->children; |
3 | 454 else if(GTK_IS_LIST(widget)) |
455 list = GTK_LIST(widget)->children; | |
456 else | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
457 return FALSE; |
3 | 458 |
459 while(list) | |
460 { | |
461 if(list->data == (gpointer)child) | |
462 { | |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
463 if(!gtk_object_get_data(GTK_OBJECT(work.window), "_dw_appending")) |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
464 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
465 gtk_object_set_data(GTK_OBJECT(work.window), "_dw_item", (gpointer)item); |
115
2d121d4d90c0
Run the _item_select_event() handler on comboboxes even if a handler
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
114
diff
changeset
|
466 if(selectfunc) |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
467 retval = selectfunc(work.window, item, work.data); |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
468 } |
3 | 469 break; |
470 } | |
471 item++; | |
472 list = list->next; | |
473 } | |
39
3aa9ef0b3996
Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
37
diff
changeset
|
474 _dw_recursing = 0; |
3 | 475 } |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
476 return retval; |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
477 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
478 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
479 static gint _container_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data) |
3 | 480 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
481 SignalHandler work = _get_signal_handler(widget, data); |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
482 int retval = FALSE; |
3 | 483 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
484 if(work.window) |
3 | 485 { |
486 if(event->button == 3) | |
487 { | |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
488 int (*contextfunc)(HWND, char *, int, int, void *, void *) = work.func; |
3 | 489 char *text; |
490 int row, col; | |
491 | |
492 gtk_clist_get_selection_info(GTK_CLIST(widget), event->x, event->y, &row, &col); | |
493 | |
494 text = (char *)gtk_clist_get_row_data(GTK_CLIST(widget), row); | |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
495 retval = contextfunc(work.window, text, event->x, event->y, work.data, NULL); |
3 | 496 } |
497 } | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
498 return retval; |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
499 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
500 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
501 static gint _tree_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data) |
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
|
502 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
503 SignalHandler work = _get_signal_handler(widget, data); |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
504 int retval = FALSE; |
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
|
505 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
506 if(work.window) |
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
|
507 { |
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
|
508 if(event->button == 3) |
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
|
509 { |
140
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
510 #if GTK_MAJOR_VERSION > 1 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
511 int (*contextfunc)(HWND, char *, int, int, void *, void *) = work.func; |
140
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
512 char *text = NULL; |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
513 void *itemdata = NULL; |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
514 |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
515 if(widget && GTK_IS_TREE_VIEW(widget)) |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
516 { |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
517 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget)); |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
518 GtkTreeIter iter; |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
519 |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
520 if(sel && gtk_tree_selection_get_selected(sel, NULL, &iter)) |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
521 { |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
522 GtkTreeModel *store = (GtkTreeModel *)gtk_object_get_data(GTK_OBJECT(widget), "_dw_tree_store"); |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
523 gtk_tree_model_get(store, &iter, 0, &text, 2, &itemdata, -1); |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
524 } |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
525 } |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
526 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
527 retval = contextfunc(work.window, text, event->x, event->y, work.data, itemdata); |
140
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
528 #else |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
529 int (*contextfunc)(HWND, char *, int, int, void *, void *) = work.func; |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
530 char *text = (char *)gtk_object_get_data(GTK_OBJECT(widget), "_dw_text"); |
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
531 void *itemdata = (void *)gtk_object_get_data(GTK_OBJECT(widget), "_dw_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
|
532 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
533 if(widget != work.window) |
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
|
534 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
535 GtkWidget *tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(work.window)); |
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
|
536 |
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
|
537 if(tree && GTK_IS_TREE(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
|
538 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
539 GtkWidget *lastselect = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_lastselect"); |
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
|
540 |
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
|
541 if(lastselect && GTK_IS_TREE_ITEM(lastselect)) |
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
|
542 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
543 text = (char *)gtk_object_get_data(GTK_OBJECT(lastselect), "_dw_text"); |
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
544 itemdata = (void *)gtk_object_get_data(GTK_OBJECT(lastselect), "_dw_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
|
545 } |
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
|
546 } |
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
|
547 } |
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
|
548 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
549 retval = contextfunc(work.window, text, event->x, event->y, work.data, itemdata); |
140
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
550 #endif |
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
|
551 } |
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
|
552 } |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
553 return retval; |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
554 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
555 |
140
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
556 #if GTK_MAJOR_VERSION > 1 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
557 static gint _tree_select_event(GtkTreeSelection *sel, gpointer data) |
140
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
558 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
559 GtkWidget *item, *widget = (GtkWidget *)gtk_tree_selection_get_tree_view(sel); |
140
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
560 int retval = FALSE; |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
561 |
362
eb61b854fd58
Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
361
diff
changeset
|
562 if(widget) |
eb61b854fd58
Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
361
diff
changeset
|
563 { |
eb61b854fd58
Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
361
diff
changeset
|
564 SignalHandler work = _get_signal_handler(widget, data); |
eb61b854fd58
Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
361
diff
changeset
|
565 |
eb61b854fd58
Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
361
diff
changeset
|
566 if(work.window) |
140
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
567 { |
362
eb61b854fd58
Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
361
diff
changeset
|
568 int (*treeselectfunc)(HWND, HTREEITEM, char *, void *, void *) = work.func; |
eb61b854fd58
Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
361
diff
changeset
|
569 GtkTreeIter iter; |
eb61b854fd58
Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
361
diff
changeset
|
570 char *text = NULL; |
eb61b854fd58
Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
361
diff
changeset
|
571 void *itemdata = NULL; |
eb61b854fd58
Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
361
diff
changeset
|
572 |
eb61b854fd58
Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
361
diff
changeset
|
573 if(gtk_tree_selection_get_selected(sel, NULL, &iter)) |
eb61b854fd58
Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
361
diff
changeset
|
574 { |
eb61b854fd58
Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
361
diff
changeset
|
575 GtkTreeModel *store = (GtkTreeModel *)gtk_object_get_data(GTK_OBJECT(widget), "_dw_tree_store"); |
eb61b854fd58
Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
361
diff
changeset
|
576 gtk_tree_model_get(store, &iter, 0, &text, 2, &itemdata, 3, &item, -1); |
eb61b854fd58
Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
361
diff
changeset
|
577 retval = treeselectfunc(work.window, (HTREEITEM)item, text, work.data, itemdata); |
eb61b854fd58
Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
361
diff
changeset
|
578 } |
140
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
579 } |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
580 } |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
581 return retval; |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
582 } |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
583 #else |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
584 static gint _tree_select_event(GtkTree *tree, GtkWidget *child, gpointer data) |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
585 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
586 SignalHandler work = _get_signal_handler((GtkWidget *)tree, data); |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
587 GtkWidget *treeroot = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(child), "_dw_tree"); |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
588 int retval = FALSE; |
107
cd0e5cf92f6a
Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
96
diff
changeset
|
589 |
cd0e5cf92f6a
Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
96
diff
changeset
|
590 if(treeroot && GTK_IS_TREE(treeroot)) |
cd0e5cf92f6a
Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
96
diff
changeset
|
591 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
592 GtkWidget *lastselect = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(treeroot), "_dw_lastselect"); |
107
cd0e5cf92f6a
Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
96
diff
changeset
|
593 if(lastselect && GTK_IS_TREE_ITEM(lastselect)) |
cd0e5cf92f6a
Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
96
diff
changeset
|
594 gtk_tree_item_deselect(GTK_TREE_ITEM(lastselect)); |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
595 gtk_object_set_data(GTK_OBJECT(treeroot), "_dw_lastselect", (gpointer)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:
96
diff
changeset
|
596 } |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
597 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
598 if(work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
599 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
600 int (*treeselectfunc)(HWND, HTREEITEM, char *, void *, void *) = work.func; |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
601 char *text = (char *)gtk_object_get_data(GTK_OBJECT(child), "_dw_text"); |
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
602 void *itemdata = (void *)gtk_object_get_data(GTK_OBJECT(child), "_dw_itemdata"); |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
603 retval = treeselectfunc(work.window, (HTREEITEM)child, text, work.data, itemdata); |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
604 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
605 return retval; |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
606 } |
140
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
607 #endif |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
608 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
609 static gint _container_select_event(GtkWidget *widget, GdkEventButton *event, gpointer data) |
3 | 610 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
611 SignalHandler work = _get_signal_handler(widget, data); |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
612 int retval = FALSE; |
3 | 613 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
614 if(work.window) |
3 | 615 { |
616 if(event->button == 1 && event->type == GDK_2BUTTON_PRESS) | |
617 { | |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
618 int (*contextfunc)(HWND, char *, void *) = work.func; |
3 | 619 char *text; |
620 int row, col; | |
621 | |
622 gtk_clist_get_selection_info(GTK_CLIST(widget), event->x, event->y, &row, &col); | |
623 | |
624 text = (char *)gtk_clist_get_row_data(GTK_CLIST(widget), row); | |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
625 retval = contextfunc(work.window, text, work.data); |
320
ae5b1eecea12
Don't send a DW_SIGNAL_ITEM_SELECT after DW_SIGNAL_ENTER.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
319
diff
changeset
|
626 gtk_object_set_data(GTK_OBJECT(widget), "_dw_double_click", (gpointer)1); |
3 | 627 } |
628 } | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
629 return retval; |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
630 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
631 |
364
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
632 static gint _container_enter_event(GtkWidget *widget, GdkEventKey *event, gpointer data) |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
633 { |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
634 SignalHandler work = _get_signal_handler(widget, data); |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
635 int retval = FALSE; |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
636 |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
637 if(work.window && event->keyval == VK_RETURN) |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
638 { |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
639 int (*contextfunc)(HWND, char *, void *) = work.func; |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
640 char *text; |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
641 |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
642 text = (char *)gtk_clist_get_row_data(GTK_CLIST(widget), GTK_CLIST(widget)->focus_row); |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
643 retval = contextfunc(work.window, text, work.data); |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
644 } |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
645 return retval; |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
646 } |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
647 |
345
599644ca9064
Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
340
diff
changeset
|
648 /* Return the logical page id from the physical page id */ |
599644ca9064
Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
340
diff
changeset
|
649 int _get_logical_page(HWND handle, unsigned long pageid) |
599644ca9064
Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
340
diff
changeset
|
650 { |
599644ca9064
Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
340
diff
changeset
|
651 int z; |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
652 GtkWidget **pagearray = gtk_object_get_data(GTK_OBJECT(handle), "_dw_pagearray"); |
345
599644ca9064
Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
340
diff
changeset
|
653 GtkWidget *thispage = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), pageid); |
599644ca9064
Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
340
diff
changeset
|
654 |
599644ca9064
Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
340
diff
changeset
|
655 if(pagearray && thispage) |
599644ca9064
Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
340
diff
changeset
|
656 { |
599644ca9064
Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
340
diff
changeset
|
657 for(z=0;z<256;z++) |
599644ca9064
Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
340
diff
changeset
|
658 { |
599644ca9064
Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
340
diff
changeset
|
659 if(thispage == pagearray[z]) |
599644ca9064
Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
340
diff
changeset
|
660 return z; |
599644ca9064
Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
340
diff
changeset
|
661 } |
599644ca9064
Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
340
diff
changeset
|
662 } |
599644ca9064
Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
340
diff
changeset
|
663 return 256; |
599644ca9064
Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
340
diff
changeset
|
664 } |
599644ca9064
Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
340
diff
changeset
|
665 |
599644ca9064
Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
340
diff
changeset
|
666 |
331
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
667 static gint _switch_page_event(GtkNotebook *notebook, GtkNotebookPage *page, guint page_num, gpointer data) |
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
668 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
669 SignalHandler work = _get_signal_handler((GtkWidget *)notebook, data); |
331
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
670 int retval = FALSE; |
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
671 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
672 if(work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
673 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
674 int (*switchpagefunc)(HWND, unsigned long, void *) = work.func; |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
675 retval = switchpagefunc(work.window, _get_logical_page(GTK_WIDGET(notebook), page_num), work.data); |
331
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
676 } |
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
677 return retval; |
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
678 } |
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
679 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
680 static gint _container_select_row(GtkWidget *widget, gint row, gint column, GdkEventButton *event, gpointer data) |
164
d35771f70bdd
Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
163
diff
changeset
|
681 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
682 SignalHandler work = _get_signal_handler(widget, data); |
164
d35771f70bdd
Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
163
diff
changeset
|
683 char *rowdata = gtk_clist_get_row_data(GTK_CLIST(widget), row); |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
684 int (*contextfunc)(HWND, HWND, char *, void *, void *) = work.func; |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
685 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
686 if(!work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
687 return TRUE; |
311
24c1dfffe97e
Unified the callback functions for tree and container widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
310
diff
changeset
|
688 |
320
ae5b1eecea12
Don't send a DW_SIGNAL_ITEM_SELECT after DW_SIGNAL_ENTER.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
319
diff
changeset
|
689 if(gtk_object_get_data(GTK_OBJECT(widget), "_dw_double_click")) |
ae5b1eecea12
Don't send a DW_SIGNAL_ITEM_SELECT after DW_SIGNAL_ENTER.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
319
diff
changeset
|
690 { |
ae5b1eecea12
Don't send a DW_SIGNAL_ITEM_SELECT after DW_SIGNAL_ENTER.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
319
diff
changeset
|
691 gtk_object_set_data(GTK_OBJECT(widget), "_dw_double_click", (gpointer)0); |
ae5b1eecea12
Don't send a DW_SIGNAL_ITEM_SELECT after DW_SIGNAL_ENTER.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
319
diff
changeset
|
692 return TRUE; |
ae5b1eecea12
Don't send a DW_SIGNAL_ITEM_SELECT after DW_SIGNAL_ENTER.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
319
diff
changeset
|
693 } |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
694 return contextfunc(work.window, 0, rowdata, work.data, 0);; |
164
d35771f70bdd
Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
163
diff
changeset
|
695 } |
d35771f70bdd
Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
163
diff
changeset
|
696 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
697 static int _round_value(gfloat val) |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
698 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
699 int newval = (int)val; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
700 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
701 if(val >= 0.5 + (gfloat)newval) |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
702 newval++; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
703 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
704 return newval; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
705 } |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
706 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
707 static gint _value_changed_event(GtkAdjustment *adjustment, gpointer data) |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
708 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
709 int max = _round_value(adjustment->upper); |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
710 int val = _round_value(adjustment->value); |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
711 GtkWidget *slider = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(adjustment), "_dw_slider"); |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
712 GtkWidget *scrollbar = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(adjustment), "_dw_scrollbar"); |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
713 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
714 if(slider) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
715 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
716 SignalHandler work = _get_signal_handler((GtkWidget *)adjustment, data); |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
717 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
718 if(work.window) |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
719 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
720 int (*valuechangedfunc)(HWND, int, void *) = work.func; |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
721 |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
722 if(GTK_IS_VSCALE(slider)) |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
723 valuechangedfunc(work.window, (max - val) - 1, work.data); |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
724 else |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
725 valuechangedfunc(work.window, val, work.data); |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
726 } |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
727 } |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
728 else if(scrollbar) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
729 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
730 SignalHandler work = _get_signal_handler((GtkWidget *)adjustment, data); |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
731 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
732 if(work.window) |
208
5349a0735fda
Hopefully fixed value_changed signal handler on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
205
diff
changeset
|
733 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
734 int (*valuechangedfunc)(HWND, int, void *) = work.func; |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
735 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
736 valuechangedfunc(work.window, val, work.data); |
208
5349a0735fda
Hopefully fixed value_changed signal handler on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
205
diff
changeset
|
737 } |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
738 } |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
739 return FALSE; |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
740 } |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
741 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
742 static gint _default_key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data) |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
743 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
744 GtkWidget *next = (GtkWidget *)data; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
745 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
746 if(next) |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
747 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
748 if(event->keyval == GDK_Return) |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
749 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
750 if(GTK_IS_BUTTON(next)) |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
751 gtk_signal_emit_by_name(GTK_OBJECT(next), "clicked"); |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
752 else |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
753 gtk_widget_grab_focus(next); |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
754 } |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
755 } |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
756 return FALSE; |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
757 } |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
758 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
759 static GdkPixmap *_find_private_pixmap(GdkBitmap **bitmap, long id, unsigned long *userwidth, unsigned long *userheight) |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
760 { |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
761 if(id < _PixmapCount && _PixmapArray[id].used) |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
762 { |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
763 *bitmap = _PixmapArray[id].mask; |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
764 if(userwidth) |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
765 *userwidth = _PixmapArray[id].width; |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
766 if(userheight) |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
767 *userheight = _PixmapArray[id].height; |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
768 return _PixmapArray[id].pixmap; |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
769 } |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
770 return NULL; |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
771 } |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
772 |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
773 static GdkPixmap *_find_pixmap(GdkBitmap **bitmap, long id, HWND handle, unsigned long *userwidth, unsigned long *userheight) |
3 | 774 { |
775 char *data = NULL; | |
776 int z; | |
777 | |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
778 if(id & (1 << 31)) |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
779 return _find_private_pixmap(bitmap, (id & 0xFFFFFF), userwidth, userheight); |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
780 |
3 | 781 for(z=0;z<_resources.resource_max;z++) |
782 { | |
783 if(_resources.resource_id[z] == id) | |
784 { | |
785 data = _resources.resource_data[z]; | |
786 break; | |
787 } | |
788 } | |
789 | |
790 if(data) | |
791 { | |
792 GdkPixmap *icon_pixmap = NULL; | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
793 #if GTK_MAJOR_VERSION > 1 |
121
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
794 GdkPixbuf *icon_pixbuf = gdk_pixbuf_new_from_xpm_data((const char **)data); |
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
795 |
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
796 if(userwidth) |
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
797 *userwidth = gdk_pixbuf_get_width(icon_pixbuf); |
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
798 if(userheight) |
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
799 *userheight = gdk_pixbuf_get_height(icon_pixbuf); |
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
800 |
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
801 gdk_pixbuf_render_pixmap_and_mask(icon_pixbuf, &icon_pixmap, bitmap, 1); |
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
802 g_object_unref(icon_pixbuf); |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
803 #elif defined(USE_IMLIB) |
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
|
804 gdk_imlib_data_to_pixmap((char **)data, &icon_pixmap, bitmap); |
3 | 805 #else |
121
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
806 icon_pixmap = gdk_pixmap_create_from_xpm_d(handle->window, bitmap, &_colors[DW_CLR_PALEGRAY], (char **)data); |
3 | 807 #endif |
808 return icon_pixmap; | |
809 } | |
810 return NULL; | |
811 } | |
812 | |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
813 #if GTK_MAJOR_VERSION > 1 |
316
a07e08f708d6
Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
312
diff
changeset
|
814 static GdkPixbuf *_find_private_pixbuf(long id) |
a07e08f708d6
Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
312
diff
changeset
|
815 { |
a07e08f708d6
Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
312
diff
changeset
|
816 if(id < _PixmapCount && _PixmapArray[id].used) |
a07e08f708d6
Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
312
diff
changeset
|
817 return _PixmapArray[id].pixbuf; |
a07e08f708d6
Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
312
diff
changeset
|
818 return NULL; |
a07e08f708d6
Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
312
diff
changeset
|
819 } |
a07e08f708d6
Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
312
diff
changeset
|
820 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
821 static GdkPixbuf *_find_pixbuf(long id) |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
822 { |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
823 char *data = NULL; |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
824 int z; |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
825 |
316
a07e08f708d6
Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
312
diff
changeset
|
826 if(id & (1 << 31)) |
a07e08f708d6
Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
312
diff
changeset
|
827 return _find_private_pixbuf((id & 0xFFFFFF)); |
a07e08f708d6
Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
312
diff
changeset
|
828 |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
829 for(z=0;z<_resources.resource_max;z++) |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
830 { |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
831 if(_resources.resource_id[z] == id) |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
832 { |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
833 data = _resources.resource_data[z]; |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
834 break; |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
835 } |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
836 } |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
837 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
838 if(data) |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
839 return gdk_pixbuf_new_from_xpm_data((const char **)data); |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
840 return NULL; |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
841 } |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
842 #endif |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
843 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
844 static void _size_allocate(GtkWindow *window) |
3 | 845 { |
846 XSizeHints sizehints; | |
847 | |
848 sizehints.base_width = 1; | |
849 sizehints.base_height = 1; | |
850 sizehints.width_inc = 1; | |
851 sizehints.height_inc = 1; | |
852 sizehints.min_width = 8; | |
853 sizehints.min_height = 8; | |
854 | |
855 sizehints.flags = (PBaseSize|PMinSize|PResizeInc); | |
856 | |
857 XSetWMNormalHints (GDK_DISPLAY(), | |
858 GDK_WINDOW_XWINDOW (GTK_WIDGET (window)->window), | |
859 &sizehints); | |
860 gdk_flush (); | |
861 } | |
862 | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
863 /* Find the index of a given thread */ |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
864 static int _find_thread_index(DWTID tid) |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
865 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
866 int z; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
867 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
868 for(z=0;z<DW_THREAD_LIMIT;z++) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
869 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
870 if(_dw_thread_list[z] == tid) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
871 return z; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
872 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
873 return 0; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
874 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
875 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
876 /* Add a thread id to the thread list */ |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
877 static void _dw_thread_add(DWTID tid) |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
878 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
879 int z; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
880 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
881 for(z=0;z<DW_THREAD_LIMIT;z++) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
882 { |
264
20becf7df38a
Prevent duplicate thread IDs from getting added to the thread list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
259
diff
changeset
|
883 if(_dw_thread_list[z] == tid) |
20becf7df38a
Prevent duplicate thread IDs from getting added to the thread list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
259
diff
changeset
|
884 return; |
20becf7df38a
Prevent duplicate thread IDs from getting added to the thread list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
259
diff
changeset
|
885 |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
886 if(_dw_thread_list[z] == (DWTID)-1) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
887 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
888 _dw_thread_list[z] = tid; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
889 _foreground[z].pixel = _foreground[z].red =_foreground[z].green = _foreground[z].blue = 0; |
372
3ef2cf70ee07
Code for drawing text with a background color on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
369
diff
changeset
|
890 _background[z].pixel = 1; |
3ef2cf70ee07
Code for drawing text with a background color on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
369
diff
changeset
|
891 _background[z].red = _background[z].green = _background[z].blue = 0; |
373
d04b0699fc28
Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
372
diff
changeset
|
892 _transparent[z] = 1; |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
893 return; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
894 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
895 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
896 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
897 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
898 /* Remove a thread id to the thread list */ |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
899 static void _dw_thread_remove(DWTID tid) |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
900 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
901 int z; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
902 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
903 for(z=0;z<DW_THREAD_LIMIT;z++) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
904 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
905 if(_dw_thread_list[z] == (DWTID)tid) |
51
d97de82f0b6e
Fix warning on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
49
diff
changeset
|
906 _dw_thread_list[z] = (DWTID)-1; |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
907 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
908 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
909 |
3 | 910 /* |
911 * Initializes the Dynamic Windows engine. | |
912 * Parameters: | |
913 * newthread: True if this is the only thread. | |
914 * False if there is already a message loop running. | |
915 */ | |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
916 int dw_int_init(DWResources *res, int newthread, int *argc, char **argv[]) |
3 | 917 { |
918 int z; | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
919 char *tmp; |
3 | 920 |
921 if(res) | |
922 { | |
923 _resources.resource_max = res->resource_max; | |
924 _resources.resource_id = res->resource_id; | |
925 _resources.resource_data = res->resource_data; | |
926 } | |
927 gtk_set_locale(); | |
928 g_thread_init(NULL); | |
135
f57ef391f104
For GTK to be thread safe in 2.0 we must call gdk_threads_init().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
134
diff
changeset
|
929 #if GTK_MAJOR_VERSION > 1 |
f57ef391f104
For GTK to be thread safe in 2.0 we must call gdk_threads_init().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
134
diff
changeset
|
930 gdk_threads_init(); |
f57ef391f104
For GTK to be thread safe in 2.0 we must call gdk_threads_init().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
134
diff
changeset
|
931 #endif |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
932 |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
933 gtk_init(argc, argv); |
3 | 934 #ifdef USE_IMLIB |
935 gdk_imlib_init(); | |
936 #endif | |
937 /* Add colors to the system colormap */ | |
938 _dw_cmap = gdk_colormap_get_system(); | |
939 for(z=0;z<16;z++) | |
940 gdk_color_alloc(_dw_cmap, &_colors[z]); | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
941 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
942 tmp = getenv("DW_BORDER_WIDTH"); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
943 if(tmp) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
944 _dw_border_width = atoi(tmp); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
945 tmp = getenv("DW_BORDER_HEIGHT"); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
946 if(tmp) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
947 _dw_border_height = atoi(tmp); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
948 |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
949 for(z=0;z<DW_THREAD_LIMIT;z++) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
950 _dw_thread_list[z] = (DWTID)-1; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
951 |
77
002da4d18ac6
Set tooltip background color to yellow.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
76
diff
changeset
|
952 gtk_rc_parse_string("style \"gtk-tooltips-style\" { bg[NORMAL] = \"#eeee00\" } widget \"gtk-tooltips\" style \"gtk-tooltips-style\""); |
002da4d18ac6
Set tooltip background color to yellow.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
76
diff
changeset
|
953 |
3 | 954 return TRUE; |
955 } | |
956 | |
957 /* | |
958 * Runs a message loop for Dynamic Windows. | |
150
2a0d7b57a6da
Removed unnecessary parameters from dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
149
diff
changeset
|
959 */ |
2a0d7b57a6da
Removed unnecessary parameters from dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
149
diff
changeset
|
960 void dw_main(void) |
3 | 961 { |
265
84471d53ab58
Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
264
diff
changeset
|
962 gdk_threads_enter(); |
3 | 963 _dw_thread = pthread_self(); |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
964 _dw_thread_add(_dw_thread); |
3 | 965 gtk_main(); |
265
84471d53ab58
Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
264
diff
changeset
|
966 _dw_thread = (pthread_t)-1; |
3 | 967 gdk_threads_leave(); |
968 } | |
969 | |
970 /* | |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
971 * Runs a message loop for Dynamic Windows, for a period of milliseconds. |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
972 * Parameters: |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
973 * 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:
60
diff
changeset
|
974 */ |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
975 void dw_main_sleep(int milliseconds) |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
976 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
977 struct timeval tv, start; |
340
eff674cb4935
Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
338
diff
changeset
|
978 pthread_t curr = pthread_self(); |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
979 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
980 gettimeofday(&start, NULL); |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
981 |
340
eff674cb4935
Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
338
diff
changeset
|
982 if(_dw_thread == (pthread_t)-1 || _dw_thread == curr) |
eff674cb4935
Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
338
diff
changeset
|
983 { |
eff674cb4935
Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
338
diff
changeset
|
984 pthread_t orig = _dw_thread; |
eff674cb4935
Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
338
diff
changeset
|
985 |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
986 gettimeofday(&tv, NULL); |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
987 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
988 while(((tv.tv_sec - start.tv_sec)*1000) + ((tv.tv_usec - start.tv_usec)/1000) <= milliseconds) |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
989 { |
340
eff674cb4935
Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
338
diff
changeset
|
990 if(orig == (pthread_t)-1) |
eff674cb4935
Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
338
diff
changeset
|
991 { |
eff674cb4935
Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
338
diff
changeset
|
992 gdk_threads_enter(); |
eff674cb4935
Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
338
diff
changeset
|
993 _dw_thread = curr; |
eff674cb4935
Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
338
diff
changeset
|
994 } |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
995 if(gtk_events_pending()) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
996 gtk_main_iteration(); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
997 else |
237
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
998 _dw_msleep(1); |
340
eff674cb4935
Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
338
diff
changeset
|
999 if(orig == (pthread_t)-1) |
eff674cb4935
Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
338
diff
changeset
|
1000 { |
eff674cb4935
Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
338
diff
changeset
|
1001 _dw_thread = orig; |
eff674cb4935
Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
338
diff
changeset
|
1002 gdk_threads_leave(); |
eff674cb4935
Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
338
diff
changeset
|
1003 } |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
1004 gettimeofday(&tv, NULL); |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1005 } |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1006 } |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1007 else |
237
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
1008 _dw_msleep(milliseconds); |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1009 } |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1010 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1011 /* |
205
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
1012 * Processes a single message iteration and returns. |
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
1013 */ |
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
1014 void dw_main_iteration(void) |
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
1015 { |
265
84471d53ab58
Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
264
diff
changeset
|
1016 gdk_threads_enter(); |
205
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
1017 _dw_thread = pthread_self(); |
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
1018 _dw_thread_add(_dw_thread); |
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
1019 gtk_main_iteration(); |
265
84471d53ab58
Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
264
diff
changeset
|
1020 _dw_thread = (pthread_t)-1; |
205
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
1021 gdk_threads_leave(); |
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
1022 } |
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
1023 |
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
1024 /* |
3 | 1025 * Free's memory allocated by dynamic windows. |
1026 * Parameters: | |
1027 * ptr: Pointer to dynamic windows allocated | |
1028 * memory to be free()'d. | |
1029 */ | |
1030 void dw_free(void *ptr) | |
1031 { | |
1032 free(ptr); | |
1033 } | |
1034 | |
1035 /* | |
1036 * Allocates and initializes a dialog struct. | |
1037 * Parameters: | |
1038 * data: User defined data to be passed to functions. | |
1039 */ | |
1040 DWDialog *dw_dialog_new(void *data) | |
1041 { | |
1042 DWDialog *tmp = malloc(sizeof(DWDialog)); | |
1043 | |
1044 tmp->eve = dw_event_new(); | |
1045 dw_event_reset(tmp->eve); | |
1046 tmp->data = data; | |
1047 tmp->done = FALSE; | |
1048 tmp->result = NULL; | |
1049 | |
1050 return tmp; | |
1051 } | |
1052 | |
1053 /* | |
1054 * Accepts a dialog struct and returns the given data to the | |
1055 * initial called of dw_dialog_wait(). | |
1056 * Parameters: | |
1057 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). | |
1058 * result: Data to be returned by dw_dialog_wait(). | |
1059 */ | |
1060 int dw_dialog_dismiss(DWDialog *dialog, void *result) | |
1061 { | |
1062 dialog->result = result; | |
41
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
1063 if(pthread_self() == _dw_thread || _dw_thread == (pthread_t)-1) |
3 | 1064 gtk_main_quit(); |
1065 else | |
1066 dw_event_post(dialog->eve); | |
1067 dialog->done = TRUE; | |
1068 return 0; | |
1069 } | |
1070 | |
1071 /* | |
1072 * Accepts a dialog struct waits for dw_dialog_dismiss() to be | |
1073 * called by a signal handler with the given dialog struct. | |
1074 * Parameters: | |
1075 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). | |
1076 */ | |
1077 void *dw_dialog_wait(DWDialog *dialog) | |
1078 { | |
1079 void *tmp; | |
41
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
1080 int newprocess = 0; |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
1081 |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
1082 /* _dw_thread will be -1 if dw_main hasn't been run yet. */ |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
1083 if(_dw_thread == (pthread_t)-1) |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
1084 { |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
1085 _dw_thread = pthread_self(); |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
1086 newprocess = 1; |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
1087 gdk_threads_enter(); |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
1088 } |
3 | 1089 |
1090 if(pthread_self() == _dw_thread) | |
1091 gtk_main(); | |
1092 else | |
1093 dw_event_wait(dialog->eve, -1); | |
1094 | |
41
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
1095 if(newprocess) |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
1096 { |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
1097 _dw_thread = (pthread_t)-1; |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
1098 gdk_threads_leave(); |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
1099 } |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
1100 |
3 | 1101 dw_event_close(&dialog->eve); |
1102 tmp = dialog->result; | |
1103 free(dialog); | |
1104 return tmp; | |
1105 } | |
1106 | |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
1107 static int _dw_ok_func(HWND window, void *data) |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1108 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1109 DWDialog *dwwait = (DWDialog *)data; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1110 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1111 if(!dwwait) |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
1112 return FALSE; |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1113 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1114 dw_window_destroy((HWND)dwwait->data); |
399
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1115 dw_dialog_dismiss((DWDialog *)data, (void *)DW_MB_RETURN_OK); |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
1116 return FALSE; |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1117 } |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1118 |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
1119 int _dw_yes_func(HWND window, void *data) |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1120 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1121 DWDialog *dwwait = (DWDialog *)data; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1122 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1123 if(!dwwait) |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
1124 return FALSE; |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1125 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1126 dw_window_destroy((HWND)dwwait->data); |
399
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1127 dw_dialog_dismiss((DWDialog *)data, (void *)DW_MB_RETURN_YES); |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
1128 return FALSE; |
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
1129 } |
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
1130 |
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
1131 int _dw_no_func(HWND window, void *data) |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1132 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1133 DWDialog *dwwait = (DWDialog *)data; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1134 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1135 if(!dwwait) |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
1136 return FALSE; |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1137 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1138 dw_window_destroy((HWND)dwwait->data); |
399
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1139 dw_dialog_dismiss((DWDialog *)data, (void *)DW_MB_RETURN_NO); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1140 return FALSE; |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1141 } |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1142 |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1143 int _dw_cancel_func(HWND window, void *data) |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1144 { |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1145 DWDialog *dwwait = (DWDialog *)data; |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1146 |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1147 if(!dwwait) |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1148 return FALSE; |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1149 |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1150 dw_window_destroy((HWND)dwwait->data); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1151 dw_dialog_dismiss((DWDialog *)data, (void *)DW_MB_RETURN_CANCEL); |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
1152 return FALSE; |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1153 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1154 |
3 | 1155 /* |
1156 * Displays a Message Box with given text and title.. | |
1157 * Parameters: | |
1158 * title: The title of the message box. | |
399
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1159 * flags: Defines buttons and icons to display |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1160 * format: printf style format string. |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1161 * ...: Additional variables for use in the format. |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1162 */ |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1163 int dw_messagebox(char *title, int flags, char *format, ...) |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1164 { |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1165 HWND entrywindow, texttargetbox, imagetextbox, mainbox, okbutton, nobutton, yesbutton, cancelbutton, buttonbox, stext; |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1166 ULONG flStyle = DW_FCF_TITLEBAR | DW_FCF_SHELLPOSITION | DW_FCF_DLGBORDER; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1167 DWDialog *dwwait; |
399
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1168 va_list args; |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1169 char outbuf[256]; |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1170 char **xpm_data = NULL; |
427
b0e2ba7c46c5
For message boxes that have icons, increase the size of the text area (and hence the
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
426
diff
changeset
|
1171 int x, y, extra_width=0; |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1172 |
399
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1173 va_start(args, format); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1174 vsprintf(outbuf, format, args); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1175 va_end(args); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1176 |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1177 entrywindow = dw_window_new(HWND_DESKTOP, title, flStyle); |
283
54aafc134652
BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
282
diff
changeset
|
1178 mainbox = dw_box_new(DW_VERT, 10); |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1179 dw_box_pack_start(entrywindow, mainbox, 0, 0, TRUE, TRUE, 0); |
401
306ce9765a61
Fixes for new message box code. Also incorporated a fix from dw_window_set
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
399
diff
changeset
|
1180 |
306ce9765a61
Fixes for new message box code. Also incorporated a fix from dw_window_set
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
399
diff
changeset
|
1181 /* determine if an icon is to be used - if so we need another HORZ box */ |
399
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1182 if((flags & DW_MB_ERROR) | (flags & DW_MB_WARNING) | (flags & DW_MB_INFORMATION) | (flags & DW_MB_QUESTION)) |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1183 { |
401
306ce9765a61
Fixes for new message box code. Also incorporated a fix from dw_window_set
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
399
diff
changeset
|
1184 imagetextbox = dw_box_new(DW_HORZ, 0); |
399
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1185 dw_box_pack_start(mainbox, imagetextbox, 0, 0, TRUE, TRUE, 2); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1186 texttargetbox = imagetextbox; |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1187 } |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1188 else |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1189 { |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1190 imagetextbox = NULL; |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1191 texttargetbox = mainbox; |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1192 } |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1193 |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1194 if(flags & DW_MB_ERROR) |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1195 xpm_data = (char **)_dw_messagebox_error; |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1196 else if(flags & DW_MB_WARNING) |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1197 xpm_data = (char **)_dw_messagebox_warning; |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1198 else if(flags & DW_MB_INFORMATION) |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1199 xpm_data = (char **)_dw_messagebox_information; |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1200 else if(flags & DW_MB_QUESTION) |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1201 xpm_data = (char **)_dw_messagebox_question; |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1202 |
427
b0e2ba7c46c5
For message boxes that have icons, increase the size of the text area (and hence the
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
426
diff
changeset
|
1203 if(xpm_data) |
b0e2ba7c46c5
For message boxes that have icons, increase the size of the text area (and hence the
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
426
diff
changeset
|
1204 extra_width = 32; |
b0e2ba7c46c5
For message boxes that have icons, increase the size of the text area (and hence the
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
426
diff
changeset
|
1205 |
399
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1206 if(texttargetbox == imagetextbox) |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1207 { |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1208 GdkPixmap *icon_pixmap = NULL; |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1209 GdkBitmap *bitmap = NULL; |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1210 HWND handle = dw_bitmap_new( 100 ); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1211 #if GTK_MAJOR_VERSION > 1 |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1212 GdkPixbuf *icon_pixbuf = gdk_pixbuf_new_from_xpm_data((const char **)xpm_data); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1213 |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1214 gdk_pixbuf_render_pixmap_and_mask(icon_pixbuf, &icon_pixmap, &bitmap, 1); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1215 g_object_unref(icon_pixbuf); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1216 #elif defined(USE_IMLIB) |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1217 gdk_imlib_data_to_pixmap((char **)xpm_data, &icon_pixmap, &bitmap); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1218 #else |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1219 icon_pixmap = gdk_pixmap_create_from_xpm_d(handle->window, &bitmap, &_colors[DW_CLR_PALEGRAY], (char **)xpm_data); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1220 #endif |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1221 |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1222 #if GTK_MAJOR_VERSION > 1 |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1223 gtk_image_set_from_pixmap(GTK_IMAGE(handle), icon_pixmap, bitmap); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1224 #else |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1225 gtk_pixmap_set(GTK_PIXMAP(handle), icon_pixmap, bitmap); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1226 #endif |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1227 |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1228 dw_box_pack_start( texttargetbox, handle, 32, 32, FALSE, FALSE, 2); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1229 } |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1230 |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1231 /* Create text */ |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1232 stext = dw_text_new(outbuf, 0); |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1233 dw_window_set_style(stext, DW_DT_WORDBREAK, DW_DT_WORDBREAK); |
427
b0e2ba7c46c5
For message boxes that have icons, increase the size of the text area (and hence the
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
426
diff
changeset
|
1234 dw_box_pack_start(texttargetbox, stext, 235+extra_width, 50, TRUE, TRUE, 2); |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1235 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1236 /* Buttons */ |
283
54aafc134652
BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
282
diff
changeset
|
1237 buttonbox = dw_box_new(DW_HORZ, 10); |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1238 |
429
f977c80a1dfa
Check for inconsistent parameters in dw_box_pack_start() and
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
427
diff
changeset
|
1239 dw_box_pack_start(mainbox, buttonbox, 0, 40, TRUE, FALSE, 0); |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1240 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1241 dwwait = dw_dialog_new((void *)entrywindow); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1242 |
401
306ce9765a61
Fixes for new message box code. Also incorporated a fix from dw_window_set
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
399
diff
changeset
|
1243 /* which buttons ? */ |
399
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1244 if(flags & DW_MB_OK) |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1245 { |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1246 okbutton = dw_button_new("Ok", 1001L); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1247 dw_box_pack_start(buttonbox, okbutton, 50, 30, TRUE, FALSE, 2); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1248 dw_signal_connect(okbutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_ok_func), (void *)dwwait); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1249 } |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1250 else if(flags & DW_MB_OKCANCEL) |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1251 { |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1252 okbutton = dw_button_new("Ok", 1001L); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1253 dw_box_pack_start(buttonbox, okbutton, 50, 30, TRUE, FALSE, 2); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1254 dw_signal_connect(okbutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_ok_func), (void *)dwwait); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1255 cancelbutton = dw_button_new("Cancel", 1002L); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1256 dw_box_pack_start(buttonbox, cancelbutton, 50, 30, TRUE, FALSE, 2); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1257 dw_signal_connect(cancelbutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_cancel_func), (void *)dwwait); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1258 } |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1259 else if(flags & DW_MB_YESNO) |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1260 { |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1261 yesbutton = dw_button_new("Yes", 1001L); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1262 dw_box_pack_start(buttonbox, yesbutton, 50, 30, TRUE, FALSE, 2); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1263 dw_signal_connect(yesbutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_yes_func), (void *)dwwait); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1264 nobutton = dw_button_new("No", 1002L); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1265 dw_box_pack_start(buttonbox, nobutton, 50, 30, TRUE, FALSE, 2); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1266 dw_signal_connect(nobutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_no_func), (void *)dwwait); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1267 } |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1268 else if(flags & DW_MB_YESNOCANCEL) |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1269 { |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1270 yesbutton = dw_button_new("Yes", 1001L); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1271 dw_box_pack_start(buttonbox, yesbutton, 50, 30, TRUE, FALSE, 2); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1272 dw_signal_connect(yesbutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_yes_func), (void *)dwwait); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1273 nobutton = dw_button_new("No", 1002L); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1274 dw_box_pack_start(buttonbox, nobutton, 50, 30, TRUE, FALSE, 2); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1275 dw_signal_connect(nobutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_no_func), (void *)dwwait); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1276 cancelbutton = dw_button_new("Cancel", 1003L); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1277 dw_box_pack_start(buttonbox, cancelbutton, 50, 30, TRUE, FALSE, 2); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1278 dw_signal_connect(cancelbutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_cancel_func), (void *)dwwait); |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1279 } |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1280 |
427
b0e2ba7c46c5
For message boxes that have icons, increase the size of the text area (and hence the
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
426
diff
changeset
|
1281 x = (dw_screen_width() - (280+extra_width))/2; |
401
306ce9765a61
Fixes for new message box code. Also incorporated a fix from dw_window_set
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
399
diff
changeset
|
1282 y = (dw_screen_height() - 150)/2; |
306ce9765a61
Fixes for new message box code. Also incorporated a fix from dw_window_set
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
399
diff
changeset
|
1283 |
427
b0e2ba7c46c5
For message boxes that have icons, increase the size of the text area (and hence the
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
426
diff
changeset
|
1284 dw_window_set_pos_size(entrywindow, x, y, (280+extra_width), 150); |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1285 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1286 dw_window_show(entrywindow); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1287 |
427
b0e2ba7c46c5
For message boxes that have icons, increase the size of the text area (and hence the
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
426
diff
changeset
|
1288 return (int)dw_dialog_wait(dwwait); |
3 | 1289 } |
1290 | |
1291 /* | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1292 * Minimizes or Iconifies a top-level window. |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1293 * Parameters: |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1294 * handle: The window handle to minimize. |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1295 */ |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1296 int dw_window_minimize(HWND handle) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1297 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1298 int _locked_by_me = FALSE; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1299 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1300 if(!handle) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1301 return 0; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1302 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1303 DW_MUTEX_LOCK; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1304 XIconifyWindow(GDK_WINDOW_XDISPLAY(GTK_WIDGET(handle)->window), |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1305 GDK_WINDOW_XWINDOW(GTK_WIDGET(handle)->window), |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1306 DefaultScreen (GDK_DISPLAY ())); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1307 DW_MUTEX_UNLOCK; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1308 return 0; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1309 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1310 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1311 /* |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1312 * Makes the window topmost. |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1313 * Parameters: |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1314 * 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
|
1315 */ |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1316 int dw_window_raise(HWND handle) |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1317 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1318 int _locked_by_me = FALSE; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1319 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1320 if(!handle) |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1321 return 0; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1322 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1323 DW_MUTEX_LOCK; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1324 gdk_window_raise(GTK_WIDGET(handle)->window); |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1325 DW_MUTEX_UNLOCK; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1326 return 0; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1327 } |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1328 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1329 /* |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1330 * Makes the window bottommost. |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1331 * Parameters: |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1332 * 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
|
1333 */ |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1334 int dw_window_lower(HWND handle) |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1335 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1336 int _locked_by_me = FALSE; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1337 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1338 if(!handle) |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1339 return 0; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1340 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1341 DW_MUTEX_LOCK; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1342 gdk_window_lower(GTK_WIDGET(handle)->window); |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1343 DW_MUTEX_UNLOCK; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1344 return 0; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1345 } |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1346 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1347 /* |
3 | 1348 * Makes the window visible. |
1349 * Parameters: | |
1350 * handle: The window handle to make visible. | |
1351 */ | |
1352 int dw_window_show(HWND handle) | |
1353 { | |
1354 int _locked_by_me = FALSE; | |
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
|
1355 GtkWidget *defaultitem; |
3 | 1356 |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1357 if(!handle) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1358 return 0; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1359 |
3 | 1360 DW_MUTEX_LOCK; |
1361 gtk_widget_show(handle); | |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1362 if(GTK_WIDGET(handle)->window) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1363 { |
272
49ac97060328
Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
271
diff
changeset
|
1364 int width = (int)gtk_object_get_data(GTK_OBJECT(handle), "_dw_width"); |
49ac97060328
Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
271
diff
changeset
|
1365 int height = (int)gtk_object_get_data(GTK_OBJECT(handle), "_dw_height"); |
49ac97060328
Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
271
diff
changeset
|
1366 |
49ac97060328
Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
271
diff
changeset
|
1367 if(width && height) |
49ac97060328
Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
271
diff
changeset
|
1368 { |
273
95bfcd2deb94
Slight change to get it to work on GTK 2.x, although there is a momentary
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
272
diff
changeset
|
1369 gtk_widget_set_usize(handle, width, height); |
272
49ac97060328
Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
271
diff
changeset
|
1370 gtk_object_set_data(GTK_OBJECT(handle), "_dw_width", 0); |
49ac97060328
Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
271
diff
changeset
|
1371 gtk_object_set_data(GTK_OBJECT(handle), "_dw_height", 0); |
49ac97060328
Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
271
diff
changeset
|
1372 } |
49ac97060328
Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
271
diff
changeset
|
1373 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1374 gdk_window_raise(GTK_WIDGET(handle)->window); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1375 gdk_flush(); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1376 gdk_window_show(GTK_WIDGET(handle)->window); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1377 gdk_flush(); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1378 } |
273
95bfcd2deb94
Slight change to get it to work on GTK 2.x, although there is a momentary
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
272
diff
changeset
|
1379 defaultitem = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_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
|
1380 if(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
|
1381 gtk_widget_grab_focus(defaultitem); |
3 | 1382 DW_MUTEX_UNLOCK; |
1383 return 0; | |
1384 } | |
1385 | |
1386 /* | |
1387 * Makes the window invisible. | |
1388 * Parameters: | |
1389 * handle: The window handle to make visible. | |
1390 */ | |
1391 int dw_window_hide(HWND handle) | |
1392 { | |
1393 int _locked_by_me = FALSE; | |
1394 | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1395 if(!handle) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1396 return 0; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1397 |
3 | 1398 DW_MUTEX_LOCK; |
1399 gtk_widget_hide(handle); | |
1400 DW_MUTEX_UNLOCK; | |
1401 return 0; | |
1402 } | |
1403 | |
1404 /* | |
1405 * Destroys a window and all of it's children. | |
1406 * Parameters: | |
1407 * handle: The window handle to destroy. | |
1408 */ | |
1409 int dw_window_destroy(HWND handle) | |
1410 { | |
1411 int _locked_by_me = FALSE; | |
1412 | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1413 if(!handle) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1414 return 0; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1415 |
3 | 1416 DW_MUTEX_LOCK; |
17
f26eced21a30
Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
15
diff
changeset
|
1417 if(GTK_IS_WIDGET(handle)) |
357
5df54ebc44dd
Fixed a bug where the eventbox associated with a box was not destroyed
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
355
diff
changeset
|
1418 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
1419 GtkWidget *eventbox = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_eventbox"); |
357
5df54ebc44dd
Fixed a bug where the eventbox associated with a box was not destroyed
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
355
diff
changeset
|
1420 |
5df54ebc44dd
Fixed a bug where the eventbox associated with a box was not destroyed
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
355
diff
changeset
|
1421 if(eventbox && GTK_IS_WIDGET(eventbox)) |
5df54ebc44dd
Fixed a bug where the eventbox associated with a box was not destroyed
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
355
diff
changeset
|
1422 gtk_widget_destroy(eventbox); |
5df54ebc44dd
Fixed a bug where the eventbox associated with a box was not destroyed
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
355
diff
changeset
|
1423 else |
5df54ebc44dd
Fixed a bug where the eventbox associated with a box was not destroyed
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
355
diff
changeset
|
1424 gtk_widget_destroy(handle); |
5df54ebc44dd
Fixed a bug where the eventbox associated with a box was not destroyed
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
355
diff
changeset
|
1425 } |
3 | 1426 DW_MUTEX_UNLOCK; |
1427 return 0; | |
1428 } | |
1429 | |
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
|
1430 /* 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
|
1431 * 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
|
1432 * 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
|
1433 */ |
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
|
1434 void dw_window_redraw(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
|
1435 { |
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
|
1436 } |
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
|
1437 |
3 | 1438 /* |
1439 * Changes a window's parent to newparent. | |
1440 * Parameters: | |
1441 * handle: The window handle to destroy. | |
1442 * newparent: The window's new parent window. | |
1443 */ | |
1444 void dw_window_reparent(HWND handle, HWND newparent) | |
1445 { | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1446 int _locked_by_me = FALSE; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1447 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1448 DW_MUTEX_LOCK; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1449 gdk_window_reparent(GTK_WIDGET(handle)->window, newparent ? GTK_WIDGET(newparent)->window : GDK_ROOT_PARENT(), 0, 0); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1450 DW_MUTEX_UNLOCK; |
3 | 1451 } |
1452 | |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
1453 static int _set_font(HWND handle, char *fontname) |
3 | 1454 { |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
1455 int retval = FALSE; |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
1456 #if GTK_MAJOR_VERSION < 2 |
3 | 1457 GtkStyle *style; |
1458 GdkFont *font = NULL; | |
1459 | |
1460 font = gdk_font_load(fontname); | |
1461 | |
1462 if(font) | |
1463 { | |
1464 style = gtk_widget_get_style(handle); | |
1465 style->font = font; | |
1466 gtk_widget_set_style(handle, style); | |
1467 retval = TRUE; | |
1468 } | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
1469 #else |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
1470 PangoFontDescription *font = pango_font_description_from_string(fontname); |
144
c68bc269ed58
Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
143
diff
changeset
|
1471 |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
1472 if(font) |
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:
145
diff
changeset
|
1473 { |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
1474 gtk_widget_modify_font(handle, font); |
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:
145
diff
changeset
|
1475 pango_font_description_free(font); |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
1476 } |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
1477 #endif |
3 | 1478 return retval; |
1479 } | |
1480 | |
1481 /* | |
1482 * Sets the font used by a specified window (widget) handle. | |
1483 * Parameters: | |
1484 * handle: The window (widget) handle. | |
1485 * fontname: Name and size of the font in the form "size.fontname" | |
1486 */ | |
1487 int dw_window_set_font(HWND handle, char *fontname) | |
1488 { | |
144
c68bc269ed58
Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
143
diff
changeset
|
1489 #if GTK_MAJOR_VERSION > 1 |
c68bc269ed58
Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
143
diff
changeset
|
1490 PangoFontDescription *pfont; |
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:
145
diff
changeset
|
1491 #else |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
1492 GdkFont *gdkfont; |
144
c68bc269ed58
Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
143
diff
changeset
|
1493 #endif |
3 | 1494 GtkWidget *handle2 = handle; |
1495 char *font; | |
1496 int _locked_by_me = FALSE; | |
1497 gpointer data; | |
1498 | |
1499 DW_MUTEX_LOCK; | |
1500 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
1501 { | |
1502 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
1503 if(tmp) | |
1504 handle2 = tmp; | |
1505 } | |
1506 font = strdup(fontname); | |
1507 | |
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:
145
diff
changeset
|
1508 #if GTK_MAJOR_VERSION < 2 |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1509 /* Free old font if it exists */ |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
1510 gdkfont = (GdkFont *)gtk_object_get_data(GTK_OBJECT(handle2), "_dw_gdkfont"); |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1511 if(gdkfont) |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1512 gdk_font_unref(gdkfont); |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1513 gdkfont = gdk_font_load(fontname); |
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:
145
diff
changeset
|
1514 if(!gdkfont) |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
1515 gdkfont = gdk_font_load("fixed"); |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
1516 gtk_object_set_data(GTK_OBJECT(handle2), "_dw_gdkfont", (gpointer)gdkfont); |
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:
145
diff
changeset
|
1517 #endif |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1518 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1519 /* Free old font name if one is allocated */ |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
1520 data = gtk_object_get_data(GTK_OBJECT(handle2), "_dw_fontname"); |
3 | 1521 if(data) |
1522 free(data); | |
1523 | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
1524 gtk_object_set_data(GTK_OBJECT(handle2), "_dw_fontname", (gpointer)font); |
144
c68bc269ed58
Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
143
diff
changeset
|
1525 #if GTK_MAJOR_VERSION > 1 |
c68bc269ed58
Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
143
diff
changeset
|
1526 pfont = pango_font_description_from_string(fontname); |
c68bc269ed58
Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
143
diff
changeset
|
1527 |
c68bc269ed58
Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
143
diff
changeset
|
1528 if(pfont) |
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:
145
diff
changeset
|
1529 { |
144
c68bc269ed58
Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
143
diff
changeset
|
1530 gtk_widget_modify_font(handle2, pfont); |
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:
145
diff
changeset
|
1531 pango_font_description_free(pfont); |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
1532 } |
144
c68bc269ed58
Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
143
diff
changeset
|
1533 #endif |
c68bc269ed58
Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
143
diff
changeset
|
1534 DW_MUTEX_UNLOCK; |
3 | 1535 return TRUE; |
1536 } | |
1537 | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1538 void _free_gdk_colors(HWND handle) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1539 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
1540 GdkColor *old = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_foregdk"); |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1541 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1542 if(old) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1543 free(old); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1544 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
1545 old = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_backgdk"); |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1546 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1547 if(old) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1548 free(old); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1549 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1550 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1551 /* Free old color pointers and allocate new ones */ |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
1552 static void _save_gdk_colors(HWND handle, GdkColor fore, GdkColor back) |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1553 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1554 GdkColor *foregdk = malloc(sizeof(GdkColor)); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1555 GdkColor *backgdk = malloc(sizeof(GdkColor)); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1556 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1557 _free_gdk_colors(handle); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1558 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1559 *foregdk = fore; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1560 *backgdk = back; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1561 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
1562 gtk_object_set_data(GTK_OBJECT(handle), "_dw_foregdk", (gpointer)foregdk); |
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
1563 gtk_object_set_data(GTK_OBJECT(handle), "_dw_backgdk", (gpointer)backgdk); |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1564 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1565 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
1566 static int _set_color(HWND handle, unsigned long fore, unsigned long back) |
3 | 1567 { |
155
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1568 /* Remember that each color component in X11 use 16 bit no matter |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1569 * what the destination display supports. (and thus GDK) |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1570 */ |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1571 GdkColor forecolor, backcolor; |
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:
145
diff
changeset
|
1572 #if GTK_MAJOR_VERSION < 2 |
155
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1573 GtkStyle *style = gtk_style_copy(gtk_widget_get_style(handle)); |
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:
145
diff
changeset
|
1574 #endif |
3 | 1575 |
155
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1576 if(fore & 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
|
1577 { |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1578 forecolor.pixel = 0; |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1579 forecolor.red = DW_RED_VALUE(fore) << 8; |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1580 forecolor.green = DW_GREEN_VALUE(fore) << 8; |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1581 forecolor.blue = DW_BLUE_VALUE(fore) << 8; |
3 | 1582 |
1583 gdk_color_alloc(_dw_cmap, &forecolor); | |
1584 | |
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:
145
diff
changeset
|
1585 #if GTK_MAJOR_VERSION > 1 |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
1586 gtk_widget_modify_text(handle, 0, &forecolor); |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
1587 gtk_widget_modify_text(handle, 1, &forecolor); |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
1588 gtk_widget_modify_fg(handle, 0, &forecolor); |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
1589 gtk_widget_modify_fg(handle, 1, &forecolor); |
155
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1590 #else |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1591 if(style) |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1592 style->text[0] = style->text[1] = style->fg[0] = style->fg[1] = forecolor; |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1593 #endif |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1594 } |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1595 else if(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
|
1596 { |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1597 forecolor = _colors[fore]; |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1598 |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1599 #if GTK_MAJOR_VERSION > 1 |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1600 gtk_widget_modify_text(handle, 0, &_colors[fore]); |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1601 gtk_widget_modify_text(handle, 1, &_colors[fore]); |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1602 gtk_widget_modify_fg(handle, 0, &_colors[fore]); |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1603 gtk_widget_modify_fg(handle, 1, &_colors[fore]); |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1604 #else |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1605 if(style) |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1606 style->text[0] = style->text[1] = style->fg[0] = style->fg[1] = _colors[fore]; |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1607 #endif |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1608 } |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1609 if(back & 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
|
1610 { |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1611 backcolor.pixel = 0; |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1612 backcolor.red = DW_RED_VALUE(back) << 8; |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1613 backcolor.green = DW_GREEN_VALUE(back) << 8; |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1614 backcolor.blue = DW_BLUE_VALUE(back) << 8; |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1615 |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1616 gdk_color_alloc(_dw_cmap, &backcolor); |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1617 |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1618 #if GTK_MAJOR_VERSION > 1 |
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:
145
diff
changeset
|
1619 gtk_widget_modify_base(handle, 0, &backcolor); |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
1620 gtk_widget_modify_base(handle, 1, &backcolor); |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
1621 gtk_widget_modify_bg(handle, 0, &backcolor); |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
1622 gtk_widget_modify_bg(handle, 1, &backcolor); |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
1623 #else |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
1624 if(style) |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
1625 style->base[0] = style->base[1] = style->bg[0] = style->bg[1] = backcolor; |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
1626 #endif |
155
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1627 } |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1628 else if(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
|
1629 { |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1630 backcolor = _colors[back]; |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1631 |
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:
145
diff
changeset
|
1632 #if GTK_MAJOR_VERSION > 1 |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
1633 gtk_widget_modify_base(handle, 0, &_colors[back]); |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
1634 gtk_widget_modify_base(handle, 1, &_colors[back]); |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
1635 gtk_widget_modify_bg(handle, 0, &_colors[back]); |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
1636 gtk_widget_modify_bg(handle, 1, &_colors[back]); |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
1637 #else |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
1638 if(style) |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
1639 style->base[0] = style->base[1] = style->bg[0] = style->bg[1] = _colors[back]; |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
1640 #endif |
155
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1641 } |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1642 |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1643 _save_gdk_colors(handle, forecolor, backcolor); |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1644 |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1645 if(GTK_IS_CLIST(handle)) |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1646 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
1647 int z, rowcount = (int)gtk_object_get_data(GTK_OBJECT(handle), "_dw_rowcount"); |
155
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1648 |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1649 for(z=0;z<rowcount;z++) |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1650 { |
155
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1651 gtk_clist_set_foreground(GTK_CLIST(handle), z, &forecolor); |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1652 gtk_clist_set_background(GTK_CLIST(handle), z, &backcolor); |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1653 } |
3 | 1654 } |
1655 | |
155
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1656 #if GTK_MAJOR_VERSION < 2 |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1657 if(style) |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1658 { |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1659 gtk_widget_set_style(handle, style); |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1660 gtk_style_unref(style); |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1661 } |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1662 #endif |
3 | 1663 return TRUE; |
1664 } | |
1665 /* | |
1666 * Sets the colors used by a specified window (widget) handle. | |
1667 * Parameters: | |
1668 * handle: The window (widget) handle. | |
1669 * fore: Foreground color in RGB format. | |
1670 * back: Background color in RGB format. | |
1671 */ | |
1672 int dw_window_set_color(HWND handle, unsigned long fore, unsigned long back) | |
1673 { | |
1674 GtkWidget *handle2 = handle; | |
1675 int _locked_by_me = FALSE; | |
1676 | |
1677 DW_MUTEX_LOCK; | |
1678 | |
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:
145
diff
changeset
|
1679 if(GTK_IS_SCROLLED_WINDOW(handle) || GTK_IS_BOX(handle)) |
3 | 1680 { |
1681 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
1682 if(tmp) | |
1683 handle2 = tmp; | |
1684 } | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1685 else if(GTK_IS_TABLE(handle)) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1686 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
1687 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_eventbox"); |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1688 if(tmp) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1689 handle2 = tmp; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1690 } |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1691 |
3 | 1692 _set_color(handle2, fore, back); |
1693 | |
1694 DW_MUTEX_UNLOCK; | |
1695 return TRUE; | |
1696 } | |
1697 | |
1698 /* | |
1699 * Sets the font used by a specified window (widget) handle. | |
1700 * Parameters: | |
1701 * handle: The window (widget) handle. | |
1702 * border: Size of the window border in pixels. | |
1703 */ | |
1704 int dw_window_set_border(HWND handle, int border) | |
1705 { | |
1706 /* TODO */ | |
1707 return 0; | |
1708 } | |
1709 | |
1710 /* | |
1711 * Captures the mouse input to this window. | |
1712 * Parameters: | |
1713 * handle: Handle to receive mouse input. | |
1714 */ | |
1715 void dw_window_capture(HWND handle) | |
1716 { | |
1717 int _locked_by_me = FALSE; | |
1718 | |
1719 DW_MUTEX_LOCK; | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1720 gdk_pointer_grab(handle->window, TRUE, GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK, NULL, NULL, GDK_CURRENT_TIME); |
3 | 1721 DW_MUTEX_UNLOCK; |
1722 } | |
1723 | |
1724 /* | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1725 * 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:
19
diff
changeset
|
1726 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1727 * 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:
19
diff
changeset
|
1728 * 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:
19
diff
changeset
|
1729 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1730 void dw_window_pointer(HWND handle, int pointertype) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1731 { |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1732 int _locked_by_me = FALSE; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1733 GdkCursor *cursor; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1734 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1735 DW_MUTEX_LOCK; |
337
e9a424e641ff
Some pointer changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
331
diff
changeset
|
1736 if(pointertype & (1 << 31)) |
e9a424e641ff
Some pointer changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
331
diff
changeset
|
1737 { |
e9a424e641ff
Some pointer changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
331
diff
changeset
|
1738 GdkBitmap *bitmap = NULL; |
338 | 1739 GdkPixmap *pixmap = _find_private_pixmap(&bitmap, (pointertype & 0xFFFFFF), NULL, NULL); |
1740 cursor = gdk_cursor_new_from_pixmap(pixmap, (GdkPixmap *)bitmap, &_colors[DW_CLR_WHITE], &_colors[DW_CLR_BLACK], 8, 8); | |
337
e9a424e641ff
Some pointer changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
331
diff
changeset
|
1741 } |
e9a424e641ff
Some pointer changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
331
diff
changeset
|
1742 else |
e9a424e641ff
Some pointer changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
331
diff
changeset
|
1743 cursor = gdk_cursor_new(pointertype); |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
1744 if(handle && handle->window) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
1745 gdk_window_set_cursor(handle->window, cursor); |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1746 gdk_cursor_destroy(cursor); |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1747 DW_MUTEX_UNLOCK; |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1748 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1749 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1750 /* |
3 | 1751 * Releases previous mouse capture. |
1752 */ | |
1753 void dw_window_release(void) | |
1754 { | |
1755 int _locked_by_me = FALSE; | |
1756 | |
1757 DW_MUTEX_LOCK; | |
1758 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
1759 DW_MUTEX_UNLOCK; | |
1760 } | |
1761 | |
1762 /* | |
1763 * Create a new Window Frame. | |
1764 * Parameters: | |
1765 * owner: The Owner's window handle or HWND_DESKTOP. | |
1766 * title: The Window title. | |
1767 * flStyle: Style flags, see the PM reference. | |
1768 */ | |
1769 HWND dw_window_new(HWND hwndOwner, char *title, unsigned long flStyle) | |
1770 { | |
1771 GtkWidget *tmp; | |
1772 int _locked_by_me = FALSE; | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1773 int flags = 0; |
3 | 1774 |
1775 DW_MUTEX_LOCK; | |
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
|
1776 last_window = tmp = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
3 | 1777 |
1778 gtk_window_set_title(GTK_WINDOW(tmp), title); | |
1779 if(!(flStyle & DW_FCF_SIZEBORDER)) | |
1780 gtk_window_set_policy(GTK_WINDOW(tmp), FALSE, FALSE, TRUE); | |
1781 | |
1782 gtk_widget_realize(tmp); | |
1783 | |
1784 if(flStyle & DW_FCF_TITLEBAR) | |
1785 flags |= GDK_DECOR_TITLE; | |
1786 | |
1787 if(flStyle & DW_FCF_MINMAX) | |
1788 flags |= GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE; | |
1789 | |
1790 if(flStyle & DW_FCF_SIZEBORDER) | |
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
|
1791 flags |= GDK_DECOR_RESIZEH | GDK_DECOR_BORDER; |
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
|
1792 |
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
|
1793 if(flStyle & DW_FCF_BORDER || flStyle & DW_FCF_DLGBORDER) |
3 | 1794 flags |= GDK_DECOR_BORDER; |
1795 | |
1796 gdk_window_set_decorations(tmp->window, flags); | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1797 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1798 if(hwndOwner) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1799 gdk_window_reparent(GTK_WIDGET(tmp)->window, GTK_WIDGET(hwndOwner)->window, 0, 0); |
3 | 1800 |
272
49ac97060328
Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
271
diff
changeset
|
1801 if(flStyle & DW_FCF_SIZEBORDER) |
49ac97060328
Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
271
diff
changeset
|
1802 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_size", (gpointer)1); |
49ac97060328
Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
271
diff
changeset
|
1803 |
3 | 1804 DW_MUTEX_UNLOCK; |
1805 return tmp; | |
1806 } | |
1807 | |
1808 /* | |
1809 * Create a new Box to be packed. | |
1810 * Parameters: | |
283
54aafc134652
BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
282
diff
changeset
|
1811 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal). |
3 | 1812 * pad: Number of pixels to pad around the box. |
1813 */ | |
1814 HWND dw_box_new(int type, int pad) | |
1815 { | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1816 GtkWidget *tmp, *eventbox; |
3 | 1817 int _locked_by_me = FALSE; |
1818 | |
1819 DW_MUTEX_LOCK; | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1820 tmp = gtk_table_new(1, 1, FALSE); |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1821 eventbox = gtk_event_box_new(); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1822 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1823 gtk_widget_show(eventbox); |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
1824 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_eventbox", (gpointer)eventbox); |
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
1825 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_boxtype", (gpointer)type); |
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
1826 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_boxpad", (gpointer)pad); |
3 | 1827 gtk_widget_show(tmp); |
1828 DW_MUTEX_UNLOCK; | |
1829 return tmp; | |
1830 } | |
1831 | |
1832 /* | |
1833 * Create a new Group Box to be packed. | |
1834 * Parameters: | |
283
54aafc134652
BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
282
diff
changeset
|
1835 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal). |
3 | 1836 * pad: Number of pixels to pad around the box. |
1837 * title: Text to be displayined in the group outline. | |
1838 */ | |
1839 HWND dw_groupbox_new(int type, int pad, char *title) | |
1840 { | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1841 GtkWidget *tmp, *frame; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1842 int _locked_by_me = FALSE; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1843 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1844 DW_MUTEX_LOCK; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1845 frame = gtk_frame_new(NULL); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1846 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1847 gtk_frame_set_label(GTK_FRAME(frame), title && *title ? title : NULL); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1848 tmp = gtk_table_new(1, 1, FALSE); |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1849 gtk_container_border_width(GTK_CONTAINER(tmp), pad); |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
1850 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_boxtype", (gpointer)type); |
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
1851 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_boxpad", (gpointer)pad); |
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
1852 gtk_object_set_data(GTK_OBJECT(frame), "_dw_boxhandle", (gpointer)tmp); |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1853 gtk_container_add(GTK_CONTAINER(frame), tmp); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1854 gtk_widget_show(tmp); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1855 gtk_widget_show(frame); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1856 DW_MUTEX_UNLOCK; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1857 return frame; |
3 | 1858 } |
1859 | |
1860 /* | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1861 * 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
|
1862 * Parameters: |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1863 * 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
|
1864 */ |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1865 HWND dw_mdi_new(unsigned long id) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1866 { |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1867 GtkWidget *tmp; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1868 int _locked_by_me = FALSE; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1869 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1870 DW_MUTEX_LOCK; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1871 tmp = gtk_vbox_new(FALSE, 0); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1872 DW_MUTEX_UNLOCK; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1873 return tmp; |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1874 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1875 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1876 /* |
3 | 1877 * Create a bitmap object to be packed. |
1878 * Parameters: | |
278
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
1879 * id: An ID to be used with dw_window_from_id() or 0L. |
3 | 1880 */ |
1881 HWND dw_bitmap_new(unsigned long id) | |
1882 { | |
121
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
1883 #if GTK_MAJOR_VERSION < 2 |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
1884 GdkPixmap *pixmap = NULL; |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
1885 GdkBitmap *bitmap = NULL; |
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
|
1886 static char * test_xpm[] = { |
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
|
1887 "1 1 2 1", |
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
|
1888 " c None", |
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
|
1889 ". c #FFFFFF", |
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
|
1890 "."}; |
121
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
1891 #endif |
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
1892 GtkWidget *tmp; |
3 | 1893 int _locked_by_me = FALSE; |
1894 | |
1895 DW_MUTEX_LOCK; | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
1896 #if GTK_MAJOR_VERSION > 1 |
121
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
1897 tmp = gtk_image_new(); |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
1898 #elif defined(USE_IMLIB) |
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
|
1899 gdk_imlib_data_to_pixmap(test_xpm, &pixmap, &bitmap); |
3 | 1900 #else |
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
|
1901 gtk_widget_realize(last_window); |
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
|
1902 |
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
|
1903 if(last_window) |
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
|
1904 pixmap = gdk_pixmap_create_from_xpm_d(last_window->window, &bitmap, &_colors[DW_CLR_PALEGRAY], test_xpm); |
3 | 1905 #endif |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
1906 #if GTK_MAJOR_VERSION < 2 |
3 | 1907 tmp = gtk_pixmap_new(pixmap, bitmap); |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
1908 #endif |
3 | 1909 gtk_widget_show(tmp); |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
1910 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
3 | 1911 DW_MUTEX_UNLOCK; |
1912 return tmp; | |
1913 } | |
1914 | |
1915 /* | |
1916 * Create a notebook object to be packed. | |
1917 * Parameters: | |
1918 * id: An ID to be used for getting the resource from the | |
1919 * resource file. | |
1920 */ | |
1921 HWND dw_notebook_new(unsigned long id, int top) | |
1922 { | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1923 GtkWidget *tmp, **pagearray = calloc(sizeof(GtkWidget *), 256); |
3 | 1924 int _locked_by_me = FALSE; |
1925 | |
1926 DW_MUTEX_LOCK; | |
1927 tmp = gtk_notebook_new(); | |
1928 if(top) | |
1929 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(tmp), GTK_POS_TOP); | |
1930 else | |
1931 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(tmp), GTK_POS_BOTTOM); | |
83
1062b0409938
Set notebook scrollable and enable popup so it will act like OS/2. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
77
diff
changeset
|
1932 gtk_notebook_set_scrollable(GTK_NOTEBOOK(tmp), TRUE); |
84
510c28aace3c
Ok the popup menu acted a bit funny so I am disabling it for now.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
83
diff
changeset
|
1933 #if 0 |
83
1062b0409938
Set notebook scrollable and enable popup so it will act like OS/2. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
77
diff
changeset
|
1934 gtk_notebook_popup_enable(GTK_NOTEBOOK(tmp)); |
84
510c28aace3c
Ok the popup menu acted a bit funny so I am disabling it for now.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
83
diff
changeset
|
1935 #endif |
3 | 1936 gtk_widget_show(tmp); |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
1937 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
1938 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_pagearray", (gpointer)pagearray); |
3 | 1939 DW_MUTEX_UNLOCK; |
1940 return tmp; | |
1941 } | |
1942 | |
1943 /* | |
1944 * Create a menu object to be popped up. | |
1945 * Parameters: | |
1946 * id: An ID to be used for getting the resource from the | |
1947 * resource file. | |
1948 */ | |
1949 HMENUI dw_menu_new(unsigned long id) | |
1950 { | |
1951 int _locked_by_me = FALSE; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1952 GtkAccelGroup *accel_group; |
185
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
1953 HMENUI tmp; |
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
1954 |
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
1955 DW_MUTEX_LOCK; |
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
1956 tmp = gtk_menu_new(); |
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
1957 gtk_widget_show(tmp); |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1958 accel_group = gtk_accel_group_new(); |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
1959 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
1960 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_accel", (gpointer)accel_group); |
3 | 1961 DW_MUTEX_UNLOCK; |
1962 return tmp; | |
1963 } | |
1964 | |
1965 /* | |
1966 * Create a menubar on a window. | |
1967 * Parameters: | |
1968 * location: Handle of a window frame to be attached to. | |
1969 */ | |
1970 HMENUI dw_menubar_new(HWND location) | |
1971 { | |
1972 GtkWidget *box; | |
1973 int _locked_by_me = FALSE; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1974 GtkAccelGroup *accel_group; |
185
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
1975 HMENUI tmp; |
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
1976 |
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
1977 DW_MUTEX_LOCK; |
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
1978 tmp = gtk_menu_bar_new(); |
3 | 1979 box = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(location)); |
185
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
1980 gtk_widget_show(tmp); |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1981 accel_group = gtk_accel_group_new(); |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
1982 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_accel", (gpointer)accel_group); |
3 | 1983 |
1984 if(box) | |
185
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
1985 gtk_box_pack_end(GTK_BOX(box), tmp, FALSE, FALSE, 0); |
3 | 1986 |
1987 DW_MUTEX_UNLOCK; | |
1988 return tmp; | |
1989 } | |
1990 | |
1991 /* | |
1992 * Destroys a menu created with dw_menubar_new or dw_menu_new. | |
1993 * Parameters: | |
1994 * menu: Handle of a menu. | |
1995 */ | |
1996 void dw_menu_destroy(HMENUI *menu) | |
1997 { | |
1998 if(menu && *menu) | |
1999 { | |
2000 int _locked_by_me = FALSE; | |
2001 | |
2002 DW_MUTEX_LOCK; | |
185
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
2003 gtk_widget_destroy(*menu); |
3 | 2004 *menu = NULL; |
2005 DW_MUTEX_UNLOCK; | |
2006 } | |
2007 } | |
2008 | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2009 char _removetilde(char *dest, char *src) |
3 | 2010 { |
2011 int z, cur=0; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2012 char accel = '\0'; |
3 | 2013 |
2014 for(z=0;z<strlen(src);z++) | |
2015 { | |
2016 if(src[z] != '~') | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2017 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2018 dest[cur] = src[z]; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2019 cur++; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2020 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2021 else |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2022 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2023 dest[cur] = '_'; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2024 accel = src[z+1]; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2025 cur++; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2026 } |
3 | 2027 } |
2028 dest[cur] = 0; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2029 return accel; |
3 | 2030 } |
2031 | |
2032 /* | |
2033 * Adds a menuitem or submenu to an existing menu. | |
2034 * Parameters: | |
2035 * menu: The handle the the existing menu. | |
2036 * title: The title text on the menu item to be added. | |
2037 * id: An ID to be used for message passing. | |
2038 * flags: Extended attributes to set on the menu. | |
2039 * end: If TRUE memu is positioned at the end of the menu. | |
2040 * check: If TRUE menu is "check"able. | |
2041 * submenu: Handle to an existing menu to be a submenu or NULL. | |
2042 */ | |
2043 HWND dw_menu_append_item(HMENUI menu, char *title, unsigned long id, unsigned long flags, int end, int check, HMENUI submenu) | |
2044 { | |
2045 GtkWidget *tmphandle; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2046 char accel, *tempbuf = malloc(strlen(title)+1); |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2047 int _locked_by_me = FALSE, submenucount; |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2048 guint tmp_key; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2049 GtkAccelGroup *accel_group; |
3 | 2050 |
185
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
2051 if(!menu) |
3 | 2052 { |
2053 free(tempbuf); | |
2054 return NULL; | |
2055 } | |
2056 | |
2057 DW_MUTEX_LOCK; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2058 accel = _removetilde(tempbuf, title); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2059 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2060 accel_group = (GtkAccelGroup *)gtk_object_get_data(GTK_OBJECT(menu), "_dw_accel"); |
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2061 submenucount = (int)gtk_object_get_data(GTK_OBJECT(menu), "_dw_submenucount"); |
3 | 2062 |
2063 if(strlen(tempbuf) == 0) | |
2064 tmphandle=gtk_menu_item_new(); | |
2065 else | |
2066 { | |
2067 if(check) | |
2068 { | |
2069 char numbuf[10]; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2070 if(accel && accel_group) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2071 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2072 tmphandle=gtk_check_menu_item_new_with_label(""); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2073 tmp_key = gtk_label_parse_uline(GTK_LABEL(GTK_BIN(tmphandle)->child), tempbuf); |
141
36dc19aa7773
Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
140
diff
changeset
|
2074 #if 0 /* This isn't working right */ |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2075 gtk_widget_add_accelerator(tmphandle, "activate", accel_group, tmp_key, GDK_MOD1_MASK, 0); |
141
36dc19aa7773
Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
140
diff
changeset
|
2076 #endif |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2077 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2078 else |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2079 tmphandle=gtk_check_menu_item_new_with_label(tempbuf); |
3 | 2080 gtk_check_menu_item_set_show_toggle(GTK_CHECK_MENU_ITEM(tmphandle), TRUE); |
2081 sprintf(numbuf, "%lu", id); | |
185
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
2082 gtk_object_set_data(GTK_OBJECT(menu), numbuf, (gpointer)tmphandle); |
3 | 2083 } |
2084 else | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2085 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2086 if(accel && accel_group) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2087 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2088 tmphandle=gtk_menu_item_new_with_label(""); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2089 tmp_key = gtk_label_parse_uline(GTK_LABEL(GTK_BIN(tmphandle)->child), tempbuf); |
141
36dc19aa7773
Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
140
diff
changeset
|
2090 #if 0 /* This isn't working right */ |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2091 gtk_widget_add_accelerator(tmphandle, "activate", accel_group, tmp_key, GDK_MOD1_MASK, 0); |
141
36dc19aa7773
Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
140
diff
changeset
|
2092 #endif |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2093 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2094 else |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2095 tmphandle=gtk_menu_item_new_with_label(tempbuf); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2096 } |
3 | 2097 } |
2098 | |
2099 gtk_widget_show(tmphandle); | |
2100 | |
2101 if(submenu) | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2102 { |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2103 char tempbuf[100]; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2104 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2105 sprintf(tempbuf, "_dw_submenu%d", submenucount); |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2106 submenucount++; |
185
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
2107 gtk_menu_item_set_submenu(GTK_MENU_ITEM(tmphandle), submenu); |
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
2108 gtk_object_set_data(GTK_OBJECT(menu), tempbuf, (gpointer)submenu); |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2109 gtk_object_set_data(GTK_OBJECT(menu), "_dw_submenucount", (gpointer)submenucount); |
185
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
2110 } |
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
2111 |
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
2112 if(GTK_IS_MENU_BAR(menu)) |
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
2113 gtk_menu_bar_append(GTK_MENU_BAR(menu), tmphandle); |
3 | 2114 else |
185
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
2115 gtk_menu_append(GTK_MENU(menu), tmphandle); |
3 | 2116 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2117 gtk_object_set_data(GTK_OBJECT(tmphandle), "_dw_id", (gpointer)id); |
3 | 2118 free(tempbuf); |
2119 DW_MUTEX_UNLOCK; | |
2120 return tmphandle; | |
2121 } | |
2122 | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2123 GtkWidget *_find_submenu_id(GtkWidget *start, char *name) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2124 { |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2125 GtkWidget *tmp; |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2126 int z, submenucount = (int)gtk_object_get_data(GTK_OBJECT(start), "_dw_submenucount"); |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2127 |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2128 if((tmp = gtk_object_get_data(GTK_OBJECT(start), name))) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2129 return tmp; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2130 |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2131 for(z=0;z<submenucount;z++) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2132 { |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2133 char tempbuf[100]; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2134 GtkWidget *submenu, *menuitem; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2135 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2136 sprintf(tempbuf, "_dw_submenu%d", z); |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2137 |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2138 if((submenu = gtk_object_get_data(GTK_OBJECT(start), tempbuf))) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2139 { |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2140 if((menuitem = _find_submenu_id(submenu, name))) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2141 return menuitem; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2142 } |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2143 } |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2144 return NULL; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2145 } |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2146 |
3 | 2147 /* |
2148 * Sets the state of a menu item check. | |
2149 * Parameters: | |
2150 * menu: The handle the the existing menu. | |
2151 * id: Menuitem id. | |
2152 * check: TRUE for checked FALSE for not checked. | |
2153 */ | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2154 void dw_menu_item_set_check(HMENUI menu, unsigned long id, int check) |
3 | 2155 { |
2156 char numbuf[10]; | |
2157 GtkWidget *tmphandle; | |
2158 int _locked_by_me = FALSE; | |
2159 | |
185
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
2160 if(!menu) |
3 | 2161 return; |
2162 | |
2163 DW_MUTEX_LOCK; | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2164 sprintf(numbuf, "%lu", id); |
185
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
2165 tmphandle = _find_submenu_id(menu, numbuf); |
3 | 2166 |
2167 if(tmphandle) | |
2168 { | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2169 _dw_ignore_click = 1; |
3 | 2170 if(GTK_CHECK_MENU_ITEM(tmphandle)->active != check) |
2171 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(tmphandle), check); | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2172 _dw_ignore_click = 0; |
3 | 2173 } |
2174 DW_MUTEX_UNLOCK; | |
2175 } | |
2176 | |
2177 /* | |
2178 * Pops up a context menu at given x and y coordinates. | |
2179 * Parameters: | |
2180 * menu: The handle the the existing menu. | |
2181 * parent: Handle to the window initiating the popup. | |
2182 * x: X coordinate. | |
2183 * y: Y coordinate. | |
2184 */ | |
2185 void dw_menu_popup(HMENUI *menu, HWND parent, int x, int y) | |
2186 { | |
2187 int _locked_by_me = FALSE; | |
2188 | |
2189 if(!menu || !*menu) | |
2190 return; | |
2191 | |
93
98cce029a611
Changed handling of menu item click events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
92
diff
changeset
|
2192 popup = parent; |
98cce029a611
Changed handling of menu item click events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
92
diff
changeset
|
2193 |
3 | 2194 DW_MUTEX_LOCK; |
185
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
2195 gtk_menu_popup(GTK_MENU(*menu), NULL, NULL, NULL, NULL, 1, GDK_CURRENT_TIME); |
3 | 2196 *menu = NULL; |
2197 DW_MUTEX_UNLOCK; | |
2198 } | |
2199 | |
2200 | |
2201 /* | |
2202 * Returns the current X and Y coordinates of the mouse pointer. | |
2203 * Parameters: | |
2204 * x: Pointer to variable to store X coordinate. | |
2205 * y: Pointer to variable to store Y coordinate. | |
2206 */ | |
2207 void dw_pointer_query_pos(long *x, long *y) | |
2208 { | |
2209 GdkModifierType state; | |
2210 int gx, gy; | |
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
|
2211 int _locked_by_me = FALSE; |
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
|
2212 |
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
|
2213 DW_MUTEX_LOCK; |
3 | 2214 gdk_window_get_pointer (GDK_ROOT_PARENT(), &gx, &gy, &state); |
2215 *x = gx; | |
2216 *y = gy; | |
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
|
2217 DW_MUTEX_UNLOCK; |
3 | 2218 } |
2219 | |
2220 /* | |
2221 * Sets the X and Y coordinates of the mouse pointer. | |
2222 * Parameters: | |
2223 * x: X coordinate. | |
2224 * y: Y coordinate. | |
2225 */ | |
2226 void dw_pointer_set_pos(long x, long y) | |
2227 { | |
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
|
2228 int _locked_by_me = FALSE; |
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
|
2229 |
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
|
2230 DW_MUTEX_LOCK; |
3 | 2231 XWarpPointer(GDK_DISPLAY(), None, GDK_ROOT_WINDOW(), 0,0,0,0, x, y); |
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
|
2232 DW_MUTEX_UNLOCK; |
3 | 2233 } |
2234 | |
2235 /* | |
2236 * Create a container object to be packed. | |
2237 * Parameters: | |
2238 * id: An ID to be used for getting the resource from the | |
2239 * resource file. | |
2240 */ | |
350
2216e65ad2ae
Removed slider flags and container selection flags from the header file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
346
diff
changeset
|
2241 HWND dw_container_new(unsigned long id, int multi) |
3 | 2242 { |
2243 GtkWidget *tmp; | |
2244 int _locked_by_me = FALSE; | |
2245 | |
2246 DW_MUTEX_LOCK; | |
2247 tmp = gtk_scrolled_window_new (NULL, NULL); | |
2248 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (tmp), | |
2249 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
2250 | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2251 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_multi", (gpointer)multi); |
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2252 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
3 | 2253 gtk_widget_show(tmp); |
2254 | |
2255 DW_MUTEX_UNLOCK; | |
2256 return tmp; | |
2257 } | |
2258 | |
2259 /* | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2260 * 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:
19
diff
changeset
|
2261 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2262 * 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:
19
diff
changeset
|
2263 * resource file. |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2264 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2265 HWND dw_tree_new(ULONG id) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2266 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2267 GtkWidget *tmp, *tree; |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
2268 #if GTK_MAJOR_VERSION > 1 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
2269 GtkTreeStore *store; |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
2270 GtkTreeViewColumn *col; |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
2271 GtkCellRenderer *rend; |
140
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
2272 GtkTreeSelection *sel; |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
2273 #endif |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2274 int _locked_by_me = FALSE; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2275 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2276 DW_MUTEX_LOCK; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2277 tmp = gtk_scrolled_window_new(NULL, NULL); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2278 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (tmp), |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
2279 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2280 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2281 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2282 gtk_widget_show(tmp); |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
2283 #if GTK_MAJOR_VERSION > 1 |
140
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
2284 store = gtk_tree_store_new(4, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_POINTER, G_TYPE_POINTER); |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
2285 tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
2286 gtk_object_set_data(GTK_OBJECT(tree), "_dw_tree_store", (gpointer)store); |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
2287 col = gtk_tree_view_column_new(); |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
2288 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
2289 rend = gtk_cell_renderer_pixbuf_new(); |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
2290 gtk_tree_view_column_pack_start(col, rend, FALSE); |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
2291 gtk_tree_view_column_add_attribute(col, rend, "pixbuf", 1); |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
2292 rend = gtk_cell_renderer_text_new(); |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
2293 gtk_tree_view_column_pack_start(col, rend, TRUE); |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
2294 gtk_tree_view_column_add_attribute(col, rend, "text", 0); |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
2295 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
2296 gtk_tree_view_append_column(GTK_TREE_VIEW (tree), col); |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
2297 gtk_tree_view_set_expander_column(GTK_TREE_VIEW(tree), col); |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
2298 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), FALSE); |
140
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
2299 |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
2300 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
2301 gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE); |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
2302 #else |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2303 tree = gtk_tree_new(); |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
2304 #endif |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2305 if(!tree) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2306 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2307 gtk_widget_destroy(tmp); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2308 DW_MUTEX_UNLOCK; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2309 return FALSE; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2310 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2311 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(tmp), tree); |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
2312 #if GTK_MAJOR_VERSION < 2 |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2313 /* Set the selection mode */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2314 gtk_tree_set_selection_mode (GTK_TREE(tree), GTK_SELECTION_SINGLE); |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
2315 gtk_tree_set_view_mode(GTK_TREE(tree), GTK_TREE_VIEW_ITEM); |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
2316 #endif |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2317 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2318 gtk_object_set_user_data(GTK_OBJECT(tmp), (gpointer)tree); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2319 gtk_widget_show(tree); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2320 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2321 DW_MUTEX_UNLOCK; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2322 return tmp; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2323 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2324 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2325 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2326 /* |
3 | 2327 * Create a new static text window (widget) to be packed. |
2328 * Parameters: | |
2329 * 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:
273
diff
changeset
|
2330 * id: An ID to be used with dw_window_from_id() or 0L. |
3 | 2331 */ |
2332 HWND dw_text_new(char *text, unsigned long id) | |
2333 { | |
2334 GtkWidget *tmp; | |
2335 int _locked_by_me = FALSE; | |
2336 | |
2337 DW_MUTEX_LOCK; | |
2338 tmp = gtk_label_new(text); | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2339 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2340 /* Left and centered */ |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2341 gtk_misc_set_alignment(GTK_MISC(tmp), 0.0f, 0.5f); |
3 | 2342 gtk_widget_show(tmp); |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2343 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
2344 gtk_misc_set_alignment(GTK_MISC(tmp), DW_LEFT, DW_LEFT); |
3 | 2345 DW_MUTEX_UNLOCK; |
2346 return tmp; | |
2347 } | |
2348 | |
2349 /* | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2350 * 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
|
2351 * Parameters: |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2352 * 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:
273
diff
changeset
|
2353 * 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
|
2354 */ |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2355 HWND dw_status_text_new(char *text, ULONG id) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2356 { |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2357 GtkWidget *tmp, *frame; |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2358 int _locked_by_me = FALSE; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2359 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2360 DW_MUTEX_LOCK; |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2361 frame = gtk_frame_new(NULL); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2362 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_IN); |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2363 tmp = gtk_label_new(text); |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2364 gtk_container_add(GTK_CONTAINER(frame), tmp); |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2365 gtk_widget_show(tmp); |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2366 gtk_widget_show(frame); |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2367 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2368 /* Left and centered */ |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2369 gtk_misc_set_alignment(GTK_MISC(tmp), 0.0f, 0.5f); |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2370 gtk_object_set_data(GTK_OBJECT(frame), "_dw_id", (gpointer)id); |
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2371 gtk_object_set_data(GTK_OBJECT(frame), "_dw_label", (gpointer)tmp); |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2372 DW_MUTEX_UNLOCK; |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2373 return frame; |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2374 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2375 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2376 /* |
3 | 2377 * Create a new Multiline Editbox window (widget) to be packed. |
2378 * Parameters: | |
278
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2379 * id: An ID to be used with dw_window_from_id() or 0L. |
3 | 2380 */ |
2381 HWND dw_mle_new(unsigned long id) | |
2382 { | |
2383 GtkWidget *tmp, *tmpbox, *scroller; | |
2384 int _locked_by_me = FALSE; | |
2385 | |
2386 DW_MUTEX_LOCK; | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2387 #if GTK_MAJOR_VERSION > 1 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2388 tmpbox = gtk_scrolled_window_new (NULL, NULL); |
144
c68bc269ed58
Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
143
diff
changeset
|
2389 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(tmpbox), |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2390 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); |
144
c68bc269ed58
Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
143
diff
changeset
|
2391 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(tmpbox), GTK_SHADOW_ETCHED_IN); |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2392 tmp = gtk_text_view_new(); |
144
c68bc269ed58
Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
143
diff
changeset
|
2393 gtk_container_add (GTK_CONTAINER(tmpbox), tmp); |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2394 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(tmp), GTK_WRAP_NONE); |
353
08e56a0f9541
dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
352
diff
changeset
|
2395 |
122
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
2396 scroller = NULL; |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2397 #else |
3 | 2398 tmpbox = gtk_hbox_new(FALSE, 0); |
2399 tmp = gtk_text_new(NULL, NULL); | |
2400 gtk_text_set_word_wrap(GTK_TEXT(tmp), FALSE); | |
2401 gtk_text_set_line_wrap(GTK_TEXT(tmp), FALSE); | |
2402 scroller = gtk_vscrollbar_new(GTK_TEXT(tmp)->vadj); | |
2403 GTK_WIDGET_UNSET_FLAGS(scroller, GTK_CAN_FOCUS); | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2404 gtk_box_pack_start(GTK_BOX(tmpbox), tmp, TRUE, TRUE, 0); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2405 gtk_box_pack_start(GTK_BOX(tmpbox), scroller, FALSE, TRUE, 0); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2406 gtk_widget_show(scroller); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2407 #endif |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2408 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
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:
145
diff
changeset
|
2409 gtk_object_set_user_data(GTK_OBJECT(tmpbox), (gpointer)tmp); |
3 | 2410 gtk_widget_show(tmp); |
2411 gtk_widget_show(tmpbox); | |
2412 DW_MUTEX_UNLOCK; | |
2413 return tmpbox; | |
2414 } | |
2415 | |
2416 /* | |
2417 * Create a new Entryfield window (widget) to be packed. | |
2418 * Parameters: | |
2419 * 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:
273
diff
changeset
|
2420 * id: An ID to be used with dw_window_from_id() or 0L. |
3 | 2421 */ |
2422 HWND dw_entryfield_new(char *text, unsigned long id) | |
2423 { | |
2424 GtkWidget *tmp; | |
2425 int _locked_by_me = FALSE; | |
2426 | |
2427 DW_MUTEX_LOCK; | |
2428 tmp = gtk_entry_new(); | |
2429 | |
2430 gtk_entry_set_text(GTK_ENTRY(tmp), text); | |
2431 | |
2432 gtk_widget_show(tmp); | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2433 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
3 | 2434 |
2435 DW_MUTEX_UNLOCK; | |
2436 return tmp; | |
2437 } | |
2438 | |
2439 /* | |
2440 * Create a new Entryfield (password) window (widget) to be packed. | |
2441 * Parameters: | |
2442 * 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:
273
diff
changeset
|
2443 * id: An ID to be used with dw_window_from_id() or 0L. |
3 | 2444 */ |
2445 HWND dw_entryfield_password_new(char *text, ULONG id) | |
2446 { | |
2447 GtkWidget *tmp; | |
2448 int _locked_by_me = FALSE; | |
2449 | |
2450 DW_MUTEX_LOCK; | |
2451 tmp = gtk_entry_new(); | |
2452 | |
2453 gtk_entry_set_visibility(GTK_ENTRY(tmp), FALSE); | |
2454 gtk_entry_set_text(GTK_ENTRY(tmp), text); | |
2455 | |
2456 gtk_widget_show(tmp); | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2457 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
3 | 2458 |
2459 DW_MUTEX_UNLOCK; | |
2460 return tmp; | |
2461 } | |
2462 | |
2463 /* | |
2464 * Create a new Combobox window (widget) to be packed. | |
2465 * Parameters: | |
2466 * 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:
273
diff
changeset
|
2467 * id: An ID to be used with dw_window_from_id() or 0L. |
3 | 2468 */ |
2469 HWND dw_combobox_new(char *text, unsigned long id) | |
2470 { | |
2471 GtkWidget *tmp; | |
424
5cc81d3c2bca
Combobox code was using the old signal handler method. Updated it to thenew
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
423
diff
changeset
|
2472 int sigid, _locked_by_me = FALSE; |
5cc81d3c2bca
Combobox code was using the old signal handler method. Updated it to thenew
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
423
diff
changeset
|
2473 gint cid; |
3 | 2474 |
2475 DW_MUTEX_LOCK; | |
2476 tmp = gtk_combo_new(); | |
2477 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(tmp)->entry), text); | |
2478 gtk_combo_set_use_arrows(GTK_COMBO(tmp), TRUE); | |
2479 gtk_object_set_user_data(GTK_OBJECT(tmp), NULL); | |
2480 gtk_widget_show(tmp); | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2481 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
115
2d121d4d90c0
Run the _item_select_event() handler on comboboxes even if a handler
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
114
diff
changeset
|
2482 |
424
5cc81d3c2bca
Combobox code was using the old signal handler method. Updated it to thenew
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
423
diff
changeset
|
2483 sigid = _set_signal_handler(GTK_COMBO(tmp)->list, tmp, NULL, NULL, NULL); |
5cc81d3c2bca
Combobox code was using the old signal handler method. Updated it to thenew
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
423
diff
changeset
|
2484 cid = gtk_signal_connect(GTK_OBJECT(GTK_COMBO(tmp)->list), "select_child", GTK_SIGNAL_FUNC(_item_select_event), (gpointer)sigid); |
5cc81d3c2bca
Combobox code was using the old signal handler method. Updated it to thenew
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
423
diff
changeset
|
2485 _set_signal_handler_id(GTK_COMBO(tmp)->list, sigid, cid); |
3 | 2486 DW_MUTEX_UNLOCK; |
2487 return tmp; | |
2488 } | |
2489 | |
2490 /* | |
2491 * Create a new button window (widget) to be packed. | |
2492 * Parameters: | |
2493 * 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:
273
diff
changeset
|
2494 * id: An ID to be used with dw_window_from_id() or 0L. |
3 | 2495 */ |
2496 HWND dw_button_new(char *text, unsigned long id) | |
2497 { | |
2498 GtkWidget *tmp; | |
2499 int _locked_by_me = FALSE; | |
2500 | |
2501 DW_MUTEX_LOCK; | |
2502 tmp = gtk_button_new_with_label(text); | |
2503 gtk_widget_show(tmp); | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2504 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
3 | 2505 DW_MUTEX_UNLOCK; |
2506 return tmp; | |
2507 } | |
2508 | |
2509 /* | |
2510 * Create a new bitmap button window (widget) to be packed. | |
2511 * Parameters: | |
2512 * text: Bubble help text to be displayed. | |
2513 * id: An ID of a bitmap in the resource file. | |
2514 */ | |
2515 HWND dw_bitmapbutton_new(char *text, unsigned long id) | |
2516 { | |
2517 GtkWidget *tmp; | |
2518 GtkWidget *bitmap; | |
2519 GtkTooltips *tooltips; | |
2520 int _locked_by_me = FALSE; | |
2521 | |
2522 DW_MUTEX_LOCK; | |
2523 tmp = gtk_button_new(); | |
2524 bitmap = dw_bitmap_new(id); | |
2525 | |
2526 if(bitmap) | |
2527 { | |
278
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2528 dw_window_set_bitmap(bitmap, id, NULL); |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2529 gtk_container_add (GTK_CONTAINER(tmp), bitmap); |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2530 } |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2531 gtk_widget_show(tmp); |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2532 if(text) |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2533 { |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2534 tooltips = gtk_tooltips_new(); |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2535 gtk_tooltips_set_tip(tooltips, tmp, text, NULL); |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2536 gtk_object_set_data(GTK_OBJECT(tmp), "tooltip", (gpointer)tooltips); |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2537 } |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2538 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
278
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2539 DW_MUTEX_UNLOCK; |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2540 return tmp; |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2541 } |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2542 |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2543 /* |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2544 * Create a new bitmap button window (widget) to be packed from a file. |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2545 * Parameters: |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2546 * text: Bubble help text to be displayed. |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2547 * id: An ID to be used with dw_window_from_id() or 0L. |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2548 * filename: Name of the file, omit extention to have |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2549 * DW pick the appropriate file extension. |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2550 * (BMP on OS/2 or Windows, XPM on Unix) |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2551 */ |
279
984db8aefd7f
Build fixes for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
278
diff
changeset
|
2552 HWND dw_bitmapbutton_new_from_file(char *text, unsigned long id, char *filename) |
278
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2553 { |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2554 GtkWidget *tmp; |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2555 GtkWidget *bitmap; |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2556 GtkTooltips *tooltips; |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2557 int _locked_by_me = FALSE; |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2558 |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2559 DW_MUTEX_LOCK; |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2560 tmp = gtk_button_new(); |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2561 bitmap = dw_bitmap_new(id); |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2562 |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2563 if(bitmap) |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2564 { |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2565 dw_window_set_bitmap(bitmap, 0, filename); |
3 | 2566 gtk_container_add (GTK_CONTAINER(tmp), bitmap); |
2567 } | |
2568 gtk_widget_show(tmp); | |
2569 if(text) | |
2570 { | |
2571 tooltips = gtk_tooltips_new(); | |
2572 gtk_tooltips_set_tip(tooltips, tmp, text, NULL); | |
2573 gtk_object_set_data(GTK_OBJECT(tmp), "tooltip", (gpointer)tooltips); | |
2574 } | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2575 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
3 | 2576 DW_MUTEX_UNLOCK; |
2577 return tmp; | |
2578 } | |
2579 | |
2580 /* | |
2581 * Create a new spinbutton window (widget) to be packed. | |
2582 * Parameters: | |
2583 * 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:
273
diff
changeset
|
2584 * id: An ID to be used with dw_window_from_id() or 0L. |
3 | 2585 */ |
2586 HWND dw_spinbutton_new(char *text, unsigned long id) | |
2587 { | |
2588 GtkAdjustment *adj; | |
2589 GtkWidget *tmp; | |
2590 int _locked_by_me = FALSE; | |
2591 | |
2592 DW_MUTEX_LOCK; | |
2593 adj = (GtkAdjustment *)gtk_adjustment_new (1.0, 0.0, 100.0, 1.0, 5.0, 0.0); | |
2594 tmp = gtk_spin_button_new (adj, 0, 0); | |
2595 gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(tmp), TRUE); | |
2596 gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(tmp), TRUE); | |
2597 gtk_widget_show(tmp); | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2598 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
3 | 2599 DW_MUTEX_UNLOCK; |
2600 return tmp; | |
2601 } | |
2602 | |
2603 /* | |
2604 * Create a new radiobutton window (widget) to be packed. | |
2605 * Parameters: | |
2606 * 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:
273
diff
changeset
|
2607 * id: An ID to be used with dw_window_from_id() or 0L. |
3 | 2608 */ |
2609 HWND dw_radiobutton_new(char *text, ULONG id) | |
2610 { | |
2611 /* This will have to be fixed in the future. */ | |
2612 GtkWidget *tmp; | |
2613 int _locked_by_me = FALSE; | |
2614 | |
2615 DW_MUTEX_LOCK; | |
2616 tmp = gtk_radio_button_new_with_label(NULL, text); | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2617 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
3 | 2618 gtk_widget_show(tmp); |
2619 | |
2620 DW_MUTEX_UNLOCK; | |
2621 return tmp; | |
2622 } | |
2623 | |
2624 /* | |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2625 * 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:
60
diff
changeset
|
2626 * Parameters: |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2627 * 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:
60
diff
changeset
|
2628 * 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:
273
diff
changeset
|
2629 * 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:
60
diff
changeset
|
2630 */ |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2631 HWND dw_slider_new(int vertical, int increments, ULONG id) |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2632 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2633 GtkWidget *tmp; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2634 GtkAdjustment *adjustment; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2635 int _locked_by_me = FALSE; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2636 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2637 DW_MUTEX_LOCK; |
67
ab9b0fa6c66e
Focus fixes and removal of several hack in the OS/2 code base.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
66
diff
changeset
|
2638 adjustment = (GtkAdjustment *)gtk_adjustment_new(0, 0, (gfloat)increments, 1, 1, 1); |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2639 if(vertical) |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2640 tmp = gtk_vscale_new(adjustment); |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2641 else |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2642 tmp = gtk_hscale_new(adjustment); |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2643 gtk_widget_show(tmp); |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2644 gtk_scale_set_draw_value(GTK_SCALE(tmp), 0); |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2645 gtk_scale_set_digits(GTK_SCALE(tmp), 0); |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2646 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_adjustment", (gpointer)adjustment); |
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2647 gtk_object_set_data(GTK_OBJECT(adjustment), "_dw_slider", (gpointer)tmp); |
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2648 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2649 DW_MUTEX_UNLOCK; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2650 return tmp; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2651 } |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2652 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2653 /* |
195
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2654 * Create a new scrollbar window (widget) to be packed. |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2655 * Parameters: |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2656 * vertical: TRUE or FALSE if scrollbar is vertical. |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2657 * 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:
273
diff
changeset
|
2658 * id: An ID to be used with dw_window_from_id() or 0L. |
195
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2659 */ |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2660 HWND dw_scrollbar_new(int vertical, int increments, ULONG id) |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2661 { |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2662 GtkWidget *tmp; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2663 GtkAdjustment *adjustment; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2664 int _locked_by_me = FALSE; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2665 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2666 DW_MUTEX_LOCK; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2667 adjustment = (GtkAdjustment *)gtk_adjustment_new(0, 0, (gfloat)increments, 1, 1, 1); |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2668 if(vertical) |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2669 tmp = gtk_vscrollbar_new(adjustment); |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2670 else |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2671 tmp = gtk_hscrollbar_new(adjustment); |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2672 GTK_WIDGET_UNSET_FLAGS(tmp, GTK_CAN_FOCUS); |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2673 gtk_widget_show(tmp); |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2674 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_adjustment", (gpointer)adjustment); |
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2675 gtk_object_set_data(GTK_OBJECT(adjustment), "_dw_scrollbar", (gpointer)tmp); |
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2676 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
195
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2677 DW_MUTEX_UNLOCK; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2678 return tmp; |
196
3dc60d60007f
Fixed a missing bracket.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
195
diff
changeset
|
2679 } |
195
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2680 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2681 /* |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
2682 * Create a new percent bar window (widget) to be packed. |
3 | 2683 * Parameters: |
278
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2684 * id: An ID to be used with dw_window_from_id() or 0L. |
3 | 2685 */ |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
2686 HWND dw_percent_new(unsigned long id) |
3 | 2687 { |
2688 GtkWidget *tmp; | |
2689 int _locked_by_me = FALSE; | |
2690 | |
2691 DW_MUTEX_LOCK; | |
2692 tmp = gtk_progress_bar_new(); | |
2693 gtk_widget_show(tmp); | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2694 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
3 | 2695 DW_MUTEX_UNLOCK; |
2696 return tmp; | |
2697 } | |
2698 | |
2699 /* | |
2700 * Create a new checkbox window (widget) to be packed. | |
2701 * Parameters: | |
2702 * 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:
273
diff
changeset
|
2703 * id: An ID to be used with dw_window_from_id() or 0L. |
3 | 2704 */ |
2705 HWND dw_checkbox_new(char *text, unsigned long id) | |
2706 { | |
2707 GtkWidget *tmp; | |
2708 int _locked_by_me = FALSE; | |
2709 | |
2710 DW_MUTEX_LOCK; | |
2711 tmp = gtk_check_button_new_with_label(text); | |
2712 gtk_widget_show(tmp); | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2713 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
3 | 2714 DW_MUTEX_UNLOCK; |
2715 return tmp; | |
2716 } | |
2717 | |
2718 /* | |
2719 * Create a new listbox window (widget) to be packed. | |
2720 * Parameters: | |
278
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2721 * id: An ID to be used with dw_window_from_id() or 0L. |
3 | 2722 * multi: Multiple select TRUE or FALSE. |
2723 */ | |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2724 HWND dw_listbox_new(unsigned long id, int multi) |
3 | 2725 { |
2726 GtkWidget *tmp, *list; | |
2727 int _locked_by_me = FALSE; | |
2728 | |
2729 DW_MUTEX_LOCK; | |
2730 tmp = gtk_scrolled_window_new(NULL, NULL); | |
2731 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (tmp), | |
2732 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
2733 | |
2734 list = gtk_list_new(); | |
2735 gtk_list_set_selection_mode(GTK_LIST(list), multi ? GTK_SELECTION_MULTIPLE : GTK_SELECTION_SINGLE); | |
2736 | |
2737 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(tmp), | |
2738 list); | |
2739 gtk_object_set_user_data(GTK_OBJECT(tmp), list); | |
2740 gtk_widget_show(list); | |
2741 gtk_widget_show(tmp); | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2742 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
3 | 2743 |
2744 DW_MUTEX_UNLOCK; | |
2745 return tmp; | |
2746 } | |
2747 | |
2748 /* | |
2749 * Sets the icon used for a given window. | |
2750 * Parameters: | |
2751 * handle: Handle to the window. | |
2752 * id: An ID to be used to specify the icon. | |
2753 */ | |
2754 void dw_window_set_icon(HWND handle, unsigned long id) | |
2755 { | |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2756 GdkBitmap *bitmap = NULL; |
3 | 2757 GdkPixmap *icon_pixmap; |
2758 int _locked_by_me = FALSE; | |
2759 | |
2760 DW_MUTEX_LOCK; | |
121
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
2761 icon_pixmap = _find_pixmap(&bitmap, id, handle, NULL, NULL); |
3 | 2762 |
2763 if(handle->window && icon_pixmap) | |
2764 gdk_window_set_icon(handle->window, NULL, icon_pixmap, bitmap); | |
2765 | |
2766 DW_MUTEX_UNLOCK; | |
2767 } | |
2768 | |
2769 /* | |
2770 * Sets the bitmap used for a given static window. | |
2771 * Parameters: | |
2772 * 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:
273
diff
changeset
|
2773 * 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:
273
diff
changeset
|
2774 * (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:
273
diff
changeset
|
2775 * 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:
273
diff
changeset
|
2776 * 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:
273
diff
changeset
|
2777 * 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:
273
diff
changeset
|
2778 */ |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2779 void dw_window_set_bitmap(HWND handle, unsigned long id, char *filename) |
3 | 2780 { |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2781 GdkBitmap *bitmap = NULL; |
3 | 2782 GdkPixmap *tmp; |
2783 int _locked_by_me = FALSE; | |
2784 | |
278
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2785 if(!id && !filename) |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2786 return; |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2787 |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2788 DW_MUTEX_LOCK; |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2789 if(id) |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2790 tmp = _find_pixmap(&bitmap, id, handle, NULL, NULL); |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2791 else |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2792 { |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2793 char *file = alloca(strlen(filename) + 5); |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2794 #if GTK_MAJOR_VERSION > 1 |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2795 GdkPixbuf *pixbuf; |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2796 #elif defined(USE_IMLIB) |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2797 GdkImlibImage *image; |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2798 #endif |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2799 |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2800 if (!file) |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2801 { |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2802 DW_MUTEX_UNLOCK; |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2803 return; |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2804 } |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2805 |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2806 strcpy(file, filename); |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2807 |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2808 /* 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:
273
diff
changeset
|
2809 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:
273
diff
changeset
|
2810 { |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2811 /* Try with .xpm extention */ |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2812 strcat(file, ".xpm"); |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2813 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:
273
diff
changeset
|
2814 { |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2815 DW_MUTEX_UNLOCK; |
279
984db8aefd7f
Build fixes for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
278
diff
changeset
|
2816 return; |
278
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2817 } |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2818 } |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2819 #if GTK_MAJOR_VERSION > 1 |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2820 pixbuf = gdk_pixbuf_new_from_file(file, NULL); |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2821 |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2822 gdk_pixbuf_render_pixmap_and_mask(pixbuf, &tmp, &bitmap, 1); |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2823 g_object_unref(pixbuf); |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2824 #elif defined(USE_IMLIB) |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2825 image = gdk_imlib_load_image(file); |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2826 |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2827 gdk_imlib_render(image, image->rgb_width, image->rgb_height); |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2828 tmp = gdk_imlib_copy_image(image); |
282
916045924784
Fixed the mask in dw_window_set_bitmap() when using imlib.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
279
diff
changeset
|
2829 bitmap = gdk_imlib_copy_mask(image); |
278
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2830 gdk_imlib_destroy_image(image); |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2831 #else |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2832 tmp = gdk_pixmap_create_from_xpm(handle->window, &bitmap, &_colors[DW_CLR_PALEGRAY], file); |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2833 #endif |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2834 } |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2835 |
3 | 2836 if(tmp) |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2837 #if GTK_MAJOR_VERSION > 1 |
121
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
2838 gtk_image_set_from_pixmap(GTK_IMAGE(handle), tmp, bitmap); |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2839 #else |
3 | 2840 gtk_pixmap_set(GTK_PIXMAP(handle), tmp, bitmap); |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2841 #endif |
3 | 2842 DW_MUTEX_UNLOCK; |
2843 } | |
2844 | |
2845 /* | |
2846 * Sets the text used for a given window. | |
2847 * Parameters: | |
2848 * handle: Handle to the window. | |
407
a8124a9561c7
Fix for dw_window_set_text() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
403
diff
changeset
|
2849 * text: The text associsated with a given window. f |
3 | 2850 */ |
2851 void dw_window_set_text(HWND handle, char *text) | |
2852 { | |
2853 int _locked_by_me = FALSE; | |
2854 | |
2855 DW_MUTEX_LOCK; | |
2856 if(GTK_IS_ENTRY(handle)) | |
2857 gtk_entry_set_text(GTK_ENTRY(handle), text); | |
2858 else if(GTK_IS_COMBO(handle)) | |
2859 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(handle)->entry), text); | |
2860 else if(GTK_IS_LABEL(handle)) | |
2861 gtk_label_set_text(GTK_LABEL(handle), text); | |
402
0f0183aa2b05
Fixed dw_window_set_text() to work on buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
401
diff
changeset
|
2862 else if(GTK_IS_BUTTON(handle)) |
403
6a3ef130962f
Check that the child is actually a label before trying to operate on it.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
402
diff
changeset
|
2863 { |
407
a8124a9561c7
Fix for dw_window_set_text() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
403
diff
changeset
|
2864 #if GTK_MAJOR_VERSION < 2 |
403
6a3ef130962f
Check that the child is actually a label before trying to operate on it.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
402
diff
changeset
|
2865 GtkWidget *label = GTK_BUTTON(handle)->child; |
6a3ef130962f
Check that the child is actually a label before trying to operate on it.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
402
diff
changeset
|
2866 |
6a3ef130962f
Check that the child is actually a label before trying to operate on it.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
402
diff
changeset
|
2867 if(GTK_IS_LABEL(label)) |
6a3ef130962f
Check that the child is actually a label before trying to operate on it.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
402
diff
changeset
|
2868 gtk_label_set_text(GTK_LABEL(label), text); |
407
a8124a9561c7
Fix for dw_window_set_text() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
403
diff
changeset
|
2869 #else |
a8124a9561c7
Fix for dw_window_set_text() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
403
diff
changeset
|
2870 gtk_button_set_label(GTK_BUTTON(handle), text); |
a8124a9561c7
Fix for dw_window_set_text() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
403
diff
changeset
|
2871 #endif |
403
6a3ef130962f
Check that the child is actually a label before trying to operate on it.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
402
diff
changeset
|
2872 } |
420
0cc801c0f2b6
dw_window_set_text() on a toplevel widget from dw_window_new() now works.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
415
diff
changeset
|
2873 else if(GTK_WIDGET_TOPLEVEL(handle)) |
0cc801c0f2b6
dw_window_set_text() on a toplevel widget from dw_window_new() now works.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
415
diff
changeset
|
2874 gtk_window_set_title(GTK_WINDOW(handle), text); |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2875 else if(GTK_IS_FRAME(handle)) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2876 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2877 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_label"); |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2878 if(tmp && GTK_IS_LABEL(tmp)) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2879 gtk_label_set_text(GTK_LABEL(tmp), text); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2880 } |
3 | 2881 DW_MUTEX_UNLOCK; |
2882 } | |
2883 | |
2884 /* | |
2885 * Gets the text used for a given window. | |
2886 * Parameters: | |
2887 * handle: Handle to the window. | |
2888 * Returns: | |
2889 * text: The text associsated with a given window. | |
2890 */ | |
2891 char *dw_window_get_text(HWND handle) | |
2892 { | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2893 #if GTK_MAJOR_VERSION > 1 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2894 const char *possible = ""; |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2895 #else |
3 | 2896 char *possible = ""; |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2897 #endif |
3 | 2898 int _locked_by_me = FALSE; |
2899 | |
2900 DW_MUTEX_LOCK; | |
2901 if(GTK_IS_ENTRY(handle)) | |
2902 possible = gtk_entry_get_text(GTK_ENTRY(handle)); | |
2903 else if(GTK_IS_COMBO(handle)) | |
2904 possible = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(handle)->entry)); | |
2905 | |
2906 DW_MUTEX_UNLOCK; | |
2907 return strdup(possible); | |
2908 } | |
2909 | |
2910 /* | |
2911 * Disables given window (widget). | |
2912 * Parameters: | |
2913 * handle: Handle to the window. | |
2914 */ | |
2915 void dw_window_disable(HWND handle) | |
2916 { | |
2917 int _locked_by_me = FALSE; | |
2918 | |
2919 DW_MUTEX_LOCK; | |
2920 gtk_widget_set_sensitive(handle, FALSE); | |
2921 DW_MUTEX_UNLOCK; | |
2922 } | |
2923 | |
2924 /* | |
2925 * Enables given window (widget). | |
2926 * Parameters: | |
2927 * handle: Handle to the window. | |
2928 */ | |
2929 void dw_window_enable(HWND handle) | |
2930 { | |
2931 int _locked_by_me = FALSE; | |
2932 | |
2933 DW_MUTEX_LOCK; | |
2934 gtk_widget_set_sensitive(handle, TRUE); | |
2935 DW_MUTEX_UNLOCK; | |
2936 } | |
2937 | |
249
5a594058687f
Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
246
diff
changeset
|
2938 /* |
5a594058687f
Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
246
diff
changeset
|
2939 * Gets the child window handle with specified ID. |
5a594058687f
Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
246
diff
changeset
|
2940 * Parameters: |
5a594058687f
Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
246
diff
changeset
|
2941 * handle: Handle to the parent window. |
5a594058687f
Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
246
diff
changeset
|
2942 * id: Integer ID of the child. |
5a594058687f
Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
246
diff
changeset
|
2943 */ |
5a594058687f
Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
246
diff
changeset
|
2944 HWND API dw_window_from_id(HWND handle, int id) |
5a594058687f
Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
246
diff
changeset
|
2945 { |
267
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2946 GList *orig = NULL, *list = NULL; |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2947 int _locked_by_me = FALSE; |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2948 |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2949 DW_MUTEX_LOCK; |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2950 if(handle && GTK_IS_CONTAINER(handle)) |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2951 { |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2952 #if GTK_MAJOR_VERSION > 1 |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2953 orig = list = gtk_container_get_children(GTK_CONTAINER(handle)); |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2954 #else |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2955 orig = list = gtk_container_children(GTK_CONTAINER(handle)); |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2956 #endif |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2957 } |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2958 while(list) |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2959 { |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2960 if(GTK_IS_WIDGET(list->data)) |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2961 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2962 if(id == (int)gtk_object_get_data(GTK_OBJECT(list->data), "_dw_id")) |
267
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2963 { |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2964 HWND ret = (HWND)list->data; |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2965 g_list_free(orig); |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2966 DW_MUTEX_UNLOCK; |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2967 return ret; |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2968 } |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2969 } |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2970 list = list->next; |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2971 } |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2972 if(orig) |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2973 g_list_free(orig); |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2974 DW_MUTEX_UNLOCK; |
249
5a594058687f
Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
246
diff
changeset
|
2975 return 0L; |
5a594058687f
Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
246
diff
changeset
|
2976 } |
5a594058687f
Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
246
diff
changeset
|
2977 |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2978 void _strip_cr(char *dest, char *src) |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2979 { |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2980 int z, x = 0; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2981 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2982 for(z=0;z<strlen(src);z++) |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2983 { |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2984 if(src[z] != '\r') |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2985 { |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2986 dest[x] = src[z]; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2987 x++; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2988 } |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2989 } |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2990 dest[x] = 0; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2991 } |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2992 |
3 | 2993 /* |
2994 * Adds text to an MLE box and returns the current point. | |
2995 * Parameters: | |
2996 * handle: Handle to the MLE to be queried. | |
2997 * buffer: Text buffer to be imported. | |
2998 * startpoint: Point to start entering text. | |
2999 */ | |
3000 unsigned int dw_mle_import(HWND handle, char *buffer, int startpoint) | |
3001 { | |
3002 unsigned int tmppoint = startpoint; | |
3003 int _locked_by_me = FALSE; | |
3004 | |
3005 DW_MUTEX_LOCK; | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3006 #if GTK_MAJOR_VERSION > 1 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3007 if(GTK_IS_SCROLLED_WINDOW(handle)) |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3008 #else |
3 | 3009 if(GTK_IS_BOX(handle)) |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3010 #endif |
3 | 3011 { |
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:
145
diff
changeset
|
3012 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 3013 |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3014 #if GTK_MAJOR_VERSION > 1 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3015 if(tmp && GTK_IS_TEXT_VIEW(tmp)) |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3016 { |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3017 char *impbuf = malloc(strlen(buffer)+1); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3018 GtkTextBuffer *tbuffer; |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3019 GtkTextIter iter; |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3020 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3021 _strip_cr(impbuf, buffer); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3022 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3023 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp)); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3024 gtk_text_buffer_get_iter_at_offset(tbuffer, &iter, startpoint); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3025 gtk_text_buffer_place_cursor(tbuffer, &iter); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3026 gtk_text_buffer_insert_at_cursor(tbuffer, impbuf, -1); |
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:
145
diff
changeset
|
3027 tmppoint = (startpoint > -1 ? startpoint : 0) + strlen(impbuf); |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3028 free(impbuf); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3029 } |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3030 #else |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
3031 GdkFont *font = (GdkFont *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_gdkfont"); |
122
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3032 |
3 | 3033 if(tmp && GTK_IS_TEXT(tmp)) |
3034 { | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
3035 GdkColor *fore = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_foregdk"); |
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
3036 GdkColor *back = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_backgdk"); |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3037 char *impbuf = malloc(strlen(buffer)+1); |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3038 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3039 _strip_cr(impbuf, buffer); |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3040 |
3 | 3041 gtk_text_set_point(GTK_TEXT(tmp), startpoint < 0 ? 0 : startpoint); |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3042 gtk_text_insert(GTK_TEXT(tmp), font, fore, back, impbuf, -1); |
3 | 3043 tmppoint = gtk_text_get_point(GTK_TEXT(tmp)); |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3044 free(impbuf); |
3 | 3045 } |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3046 #endif |
3 | 3047 } |
3048 DW_MUTEX_UNLOCK; | |
3049 return tmppoint; | |
3050 } | |
3051 | |
3052 /* | |
3053 * Grabs text from an MLE box. | |
3054 * Parameters: | |
3055 * handle: Handle to the MLE to be queried. | |
3056 * buffer: Text buffer to be exported. | |
3057 * startpoint: Point to start grabbing text. | |
3058 * length: Amount of text to be grabbed. | |
3059 */ | |
3060 void dw_mle_export(HWND handle, char *buffer, int startpoint, int length) | |
3061 { | |
3062 int _locked_by_me = FALSE; | |
3063 gchar *text; | |
3064 | |
3065 DW_MUTEX_LOCK; | |
427
b0e2ba7c46c5
For message boxes that have icons, increase the size of the text area (and hence the
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
426
diff
changeset
|
3066 /* force the return value to nul in case the following tests fail */ |
b0e2ba7c46c5
For message boxes that have icons, increase the size of the text area (and hence the
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
426
diff
changeset
|
3067 if(buffer) |
b0e2ba7c46c5
For message boxes that have icons, increase the size of the text area (and hence the
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
426
diff
changeset
|
3068 strcpy(buffer,""); |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3069 #if GTK_MAJOR_VERSION > 1 |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3070 if(GTK_IS_SCROLLED_WINDOW(handle)) |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3071 #else |
3 | 3072 if(GTK_IS_BOX(handle)) |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3073 #endif |
3 | 3074 { |
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:
145
diff
changeset
|
3075 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 3076 |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3077 #if GTK_MAJOR_VERSION > 1 |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3078 if(tmp && GTK_IS_TEXT_VIEW(tmp)) |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3079 { |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3080 GtkTextBuffer *tbuffer; |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3081 GtkTextIter start, end; |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3082 |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3083 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp)); |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3084 gtk_text_buffer_get_iter_at_offset(tbuffer, &start, startpoint); |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3085 gtk_text_buffer_get_iter_at_offset(tbuffer, &end, startpoint + length); |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3086 text = gtk_text_iter_get_text(&start, &end); |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3087 if(text) /* Should this get freed? */ |
427
b0e2ba7c46c5
For message boxes that have icons, increase the size of the text area (and hence the
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
426
diff
changeset
|
3088 { |
b0e2ba7c46c5
For message boxes that have icons, increase the size of the text area (and hence the
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
426
diff
changeset
|
3089 if(buffer) |
b0e2ba7c46c5
For message boxes that have icons, increase the size of the text area (and hence the
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
426
diff
changeset
|
3090 strcpy(buffer, text); |
b0e2ba7c46c5
For message boxes that have icons, increase the size of the text area (and hence the
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
426
diff
changeset
|
3091 } |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3092 } |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3093 #else |
3 | 3094 if(tmp && GTK_IS_TEXT(tmp)) |
3095 { | |
427
b0e2ba7c46c5
For message boxes that have icons, increase the size of the text area (and hence the
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
426
diff
changeset
|
3096 text = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), startpoint, startpoint + length - 1); |
3 | 3097 if(text) |
3098 { | |
427
b0e2ba7c46c5
For message boxes that have icons, increase the size of the text area (and hence the
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
426
diff
changeset
|
3099 if(buffer) |
b0e2ba7c46c5
For message boxes that have icons, increase the size of the text area (and hence the
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
426
diff
changeset
|
3100 strcpy(buffer, text); |
3 | 3101 g_free(text); |
3102 } | |
3103 } | |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3104 #endif |
3 | 3105 } |
3106 DW_MUTEX_UNLOCK; | |
3107 } | |
3108 | |
3109 /* | |
3110 * Obtains information about an MLE box. | |
3111 * Parameters: | |
3112 * handle: Handle to the MLE to be queried. | |
3113 * bytes: A pointer to a variable to return the total bytes. | |
3114 * lines: A pointer to a variable to return the number of lines. | |
3115 */ | |
3116 void dw_mle_query(HWND handle, unsigned long *bytes, unsigned long *lines) | |
3117 { | |
3118 int _locked_by_me = FALSE; | |
3119 | |
3120 if(bytes) | |
3121 *bytes = 0; | |
3122 if(lines) | |
3123 *lines = 0; | |
3124 | |
3125 DW_MUTEX_LOCK; | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3126 #if GTK_MAJOR_VERSION > 1 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3127 if(GTK_IS_SCROLLED_WINDOW(handle)) |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3128 { |
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:
145
diff
changeset
|
3129 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3130 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3131 if(tmp && GTK_IS_TEXT_VIEW(tmp)) |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3132 { |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3133 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(tmp)); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3134 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3135 if(bytes) |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3136 *bytes = gtk_text_buffer_get_char_count(buffer) + 1; |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3137 if(lines) |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3138 *lines = gtk_text_buffer_get_line_count(buffer) + 1; |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3139 } |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3140 } |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3141 #else |
3 | 3142 if(GTK_IS_BOX(handle)) |
3143 { | |
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:
145
diff
changeset
|
3144 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 3145 |
3146 if(tmp && GTK_IS_TEXT(tmp)) | |
3147 { | |
3148 if(bytes) | |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3149 *bytes = gtk_text_get_length(GTK_TEXT(tmp)) + 1; |
3 | 3150 if(lines) |
3151 { | |
3152 gchar *text; | |
3153 | |
3154 *lines = 0; | |
386
5326544ab2ec
Change dw_mle_query() under GTK 1.2 so that it returns the correct number of lines.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
383
diff
changeset
|
3155 text = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), 0, gtk_text_get_length(GTK_TEXT(tmp))); |
3 | 3156 |
3157 if(text) | |
3158 { | |
3159 int z, len = strlen(text); | |
3160 | |
3161 for(z=0;z<len;z++) | |
3162 { | |
3163 if(text[z] == '\n') | |
3164 (*lines)++; | |
3165 } | |
3166 g_free(text); | |
3167 } | |
3168 } | |
3169 } | |
3170 } | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3171 #endif |
3 | 3172 DW_MUTEX_UNLOCK; |
3173 } | |
3174 | |
3175 /* | |
3176 * Deletes text from an MLE box. | |
3177 * Parameters: | |
3178 * handle: Handle to the MLE to be deleted from. | |
3179 * startpoint: Point to start deleting text. | |
3180 * length: Amount of text to be deleted. | |
3181 */ | |
3182 void dw_mle_delete(HWND handle, int startpoint, int length) | |
3183 { | |
3184 int _locked_by_me = FALSE; | |
3185 | |
3186 DW_MUTEX_LOCK; | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3187 #if GTK_MAJOR_VERSION > 1 |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3188 if(GTK_IS_SCROLLED_WINDOW(handle)) |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3189 #else |
3 | 3190 if(GTK_IS_BOX(handle)) |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3191 #endif |
3 | 3192 { |
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:
145
diff
changeset
|
3193 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 3194 |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3195 #if GTK_MAJOR_VERSION > 1 |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3196 if(tmp && GTK_IS_TEXT_VIEW(tmp)) |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3197 { |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3198 GtkTextBuffer *tbuffer; |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3199 GtkTextIter start, end; |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3200 |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3201 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp)); |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3202 gtk_text_buffer_get_iter_at_offset(tbuffer, &start, startpoint); |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3203 gtk_text_buffer_get_iter_at_offset(tbuffer, &end, startpoint + length); |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3204 gtk_text_buffer_delete(tbuffer, &start, &end); |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3205 } |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3206 #else |
3 | 3207 if(tmp && GTK_IS_TEXT(tmp)) |
3208 { | |
3209 gtk_text_set_point(GTK_TEXT(tmp), startpoint); | |
3210 gtk_text_forward_delete(GTK_TEXT(tmp), length); | |
3211 } | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3212 #endif |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3213 } |
3 | 3214 DW_MUTEX_UNLOCK; |
3215 } | |
3216 | |
3217 /* | |
3218 * Clears all text from an MLE box. | |
3219 * Parameters: | |
3220 * handle: Handle to the MLE to be cleared. | |
3221 */ | |
3222 void dw_mle_clear(HWND handle) | |
3223 { | |
3224 int length, _locked_by_me = FALSE; | |
3225 | |
3226 DW_MUTEX_LOCK; | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3227 #if GTK_MAJOR_VERSION > 1 |
122
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3228 if(GTK_IS_SCROLLED_WINDOW(handle)) |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3229 { |
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:
145
diff
changeset
|
3230 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
122
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3231 |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3232 if(tmp && GTK_IS_TEXT_VIEW(tmp)) |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3233 { |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3234 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(tmp)); |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3235 |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3236 length = -1; |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3237 gtk_text_buffer_set_text(buffer, "", length); |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3238 } |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3239 } |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3240 #else |
3 | 3241 if(GTK_IS_BOX(handle)) |
3242 { | |
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:
145
diff
changeset
|
3243 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 3244 |
3245 if(tmp && GTK_IS_TEXT(tmp)) | |
3246 { | |
3247 length = gtk_text_get_length(GTK_TEXT(tmp)); | |
3248 gtk_text_set_point(GTK_TEXT(tmp), 0); | |
3249 gtk_text_forward_delete(GTK_TEXT(tmp), length); | |
3250 } | |
3251 } | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3252 #endif |
3 | 3253 DW_MUTEX_UNLOCK; |
3254 } | |
3255 | |
3256 /* | |
3257 * Sets the visible line of an MLE box. | |
3258 * Parameters: | |
3259 * handle: Handle to the MLE. | |
3260 * line: Line to be visible. | |
3261 */ | |
3262 void dw_mle_set_visible(HWND handle, int line) | |
3263 { | |
3264 int _locked_by_me = FALSE; | |
3265 | |
3266 DW_MUTEX_LOCK; | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3267 #if GTK_MAJOR_VERSION > 1 |
354
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3268 if(GTK_IS_SCROLLED_WINDOW(handle)) |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3269 { |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3270 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3271 |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3272 if(tmp && GTK_IS_TEXT_VIEW(tmp)) |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3273 { |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3274 GtkTextBuffer *tbuffer; |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3275 GtkTextIter iter; |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3276 GtkTextMark *mark = (GtkTextMark *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_mark"); |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3277 |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3278 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp)); |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3279 gtk_text_buffer_get_iter_at_offset(tbuffer, &iter, 0); |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3280 gtk_text_iter_set_line(&iter, line); |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3281 if(!mark) |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3282 { |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3283 mark = gtk_text_buffer_create_mark(tbuffer, NULL, &iter, FALSE); |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3284 gtk_object_set_data(GTK_OBJECT(handle), "_dw_mark", (gpointer)mark); |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3285 } |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3286 else |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3287 gtk_text_buffer_move_mark(tbuffer, mark, &iter); |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3288 gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(tmp), mark, |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3289 0, FALSE, 0, 0); |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3290 } |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3291 } |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3292 #else |
3 | 3293 if(GTK_IS_BOX(handle)) |
3294 { | |
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:
145
diff
changeset
|
3295 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 3296 |
3297 if(tmp && GTK_IS_TEXT(tmp)) | |
3298 { | |
3299 unsigned long lines; | |
3300 float pos, ratio; | |
3301 | |
3302 dw_mle_query(handle, NULL, &lines); | |
3303 | |
3304 if(lines) | |
3305 { | |
3306 ratio = (float)line/(float)lines; | |
3307 | |
3308 pos = (ratio * (float)(GTK_TEXT(tmp)->vadj->upper - GTK_TEXT(tmp)->vadj->lower)) + GTK_TEXT(tmp)->vadj->lower; | |
3309 | |
3310 gtk_adjustment_set_value(GTK_TEXT(tmp)->vadj, pos); | |
3311 } | |
3312 } | |
3313 } | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3314 #endif |
3 | 3315 DW_MUTEX_UNLOCK; |
3316 } | |
3317 | |
3318 /* | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3319 * Sets the editablity of an MLE box. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3320 * Parameters: |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3321 * handle: Handle to the MLE. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3322 * 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
|
3323 */ |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3324 void dw_mle_set_editable(HWND handle, int state) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3325 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3326 int _locked_by_me = FALSE; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3327 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3328 DW_MUTEX_LOCK; |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3329 #if GTK_MAJOR_VERSION > 1 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3330 if(GTK_IS_SCROLLED_WINDOW(handle)) |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3331 { |
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:
145
diff
changeset
|
3332 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3333 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3334 if(tmp && GTK_IS_TEXT_VIEW(tmp)) |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3335 gtk_text_view_set_editable(GTK_TEXT_VIEW(tmp), state); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3336 } |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3337 #else |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3338 if(GTK_IS_BOX(handle)) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3339 { |
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:
145
diff
changeset
|
3340 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3341 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3342 if(tmp && GTK_IS_TEXT(tmp)) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3343 gtk_text_set_editable(GTK_TEXT(tmp), state); |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3344 } |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3345 #endif |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3346 DW_MUTEX_UNLOCK; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3347 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3348 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3349 /* |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3350 * Sets the word wrap state of an MLE box. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3351 * Parameters: |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3352 * handle: Handle to the MLE. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3353 * 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
|
3354 */ |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3355 void dw_mle_set_word_wrap(HWND handle, int state) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3356 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3357 int _locked_by_me = FALSE; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3358 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3359 DW_MUTEX_LOCK; |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3360 #if GTK_MAJOR_VERSION > 1 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3361 if(GTK_IS_SCROLLED_WINDOW(handle)) |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3362 { |
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:
145
diff
changeset
|
3363 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3364 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3365 if(tmp && GTK_IS_TEXT_VIEW(tmp)) |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3366 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(tmp), GTK_WRAP_WORD); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3367 } |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3368 #else |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3369 if(GTK_IS_BOX(handle)) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3370 { |
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:
145
diff
changeset
|
3371 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3372 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3373 if(tmp && GTK_IS_TEXT(tmp)) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3374 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3375 gtk_text_set_word_wrap(GTK_TEXT(tmp), state); |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3376 gtk_text_set_line_wrap(GTK_TEXT(tmp), state); |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3377 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3378 } |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3379 #endif |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3380 DW_MUTEX_UNLOCK; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3381 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3382 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3383 /* |
3 | 3384 * Sets the current cursor position of an MLE box. |
3385 * Parameters: | |
3386 * handle: Handle to the MLE to be positioned. | |
3387 * point: Point to position cursor. | |
3388 */ | |
3389 void dw_mle_set(HWND handle, int point) | |
3390 { | |
3391 int _locked_by_me = FALSE; | |
3392 | |
3393 DW_MUTEX_LOCK; | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3394 #if GTK_MAJOR_VERSION > 1 |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3395 if(GTK_IS_SCROLLED_WINDOW(handle)) |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3396 #else |
3 | 3397 if(GTK_IS_BOX(handle)) |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3398 #endif |
3 | 3399 { |
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:
145
diff
changeset
|
3400 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 3401 |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3402 #if GTK_MAJOR_VERSION > 1 |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3403 if(tmp && GTK_IS_TEXT_VIEW(tmp)) |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3404 { |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3405 GtkTextBuffer *tbuffer; |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3406 GtkTextIter iter; |
353
08e56a0f9541
dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
352
diff
changeset
|
3407 GtkTextMark *mark = (GtkTextMark *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_mark"); |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3408 |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3409 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp)); |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3410 gtk_text_buffer_get_iter_at_offset(tbuffer, &iter, point); |
353
08e56a0f9541
dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
352
diff
changeset
|
3411 if(!mark) |
08e56a0f9541
dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
352
diff
changeset
|
3412 { |
08e56a0f9541
dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
352
diff
changeset
|
3413 mark = gtk_text_buffer_create_mark(tbuffer, NULL, &iter, FALSE); |
08e56a0f9541
dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
352
diff
changeset
|
3414 gtk_object_set_data(GTK_OBJECT(handle), "_dw_mark", (gpointer)mark); |
08e56a0f9541
dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
352
diff
changeset
|
3415 } |
08e56a0f9541
dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
352
diff
changeset
|
3416 else |
08e56a0f9541
dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
352
diff
changeset
|
3417 gtk_text_buffer_move_mark(tbuffer, mark, &iter); |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3418 gtk_text_buffer_place_cursor(tbuffer, &iter); |
353
08e56a0f9541
dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
352
diff
changeset
|
3419 gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(tmp), mark, |
08e56a0f9541
dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
352
diff
changeset
|
3420 0, FALSE, 0, 0); |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3421 } |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3422 #else |
3 | 3423 if(tmp && GTK_IS_TEXT(tmp)) |
3424 { | |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3425 unsigned long chars; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3426 float pos, ratio; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3427 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3428 dw_mle_query(handle, &chars, NULL); |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3429 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3430 if(chars) |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3431 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3432 ratio = (float)point/(float)chars; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3433 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3434 pos = (ratio * (float)(GTK_TEXT(tmp)->vadj->upper - GTK_TEXT(tmp)->vadj->lower)) + GTK_TEXT(tmp)->vadj->lower; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3435 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3436 gtk_adjustment_set_value(GTK_TEXT(tmp)->vadj, pos); |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3437 } |
3 | 3438 gtk_text_set_point(GTK_TEXT(tmp), point); |
3439 } | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3440 #endif |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3441 } |
3 | 3442 DW_MUTEX_UNLOCK; |
3443 } | |
3444 | |
3445 /* | |
3446 * Finds text in an MLE box. | |
3447 * Parameters: | |
3448 * handle: Handle to the MLE to be cleared. | |
3449 * text: Text to search for. | |
3450 * point: Start point of search. | |
3451 * flags: Search specific flags. | |
3452 */ | |
3453 int dw_mle_search(HWND handle, char *text, int point, unsigned long flags) | |
3454 { | |
3455 int _locked_by_me = FALSE, retval = 0; | |
3456 | |
3457 DW_MUTEX_LOCK; | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3458 #if GTK_MAJOR_VERSION > 1 |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3459 if(GTK_IS_SCROLLED_WINDOW(handle)) |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3460 #else |
3 | 3461 if(GTK_IS_BOX(handle)) |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3462 #endif |
3 | 3463 { |
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:
145
diff
changeset
|
3464 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 3465 |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3466 #if GTK_MAJOR_VERSION > 1 |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3467 if(tmp && GTK_IS_TEXT_VIEW(tmp)) |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3468 { |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3469 GtkTextBuffer *tbuffer; |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3470 GtkTextIter iter, found; |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3471 |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3472 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp)); |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3473 gtk_text_buffer_get_iter_at_offset(tbuffer, &iter, point); |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3474 gtk_text_iter_forward_search(&iter, text, GTK_TEXT_SEARCH_TEXT_ONLY, &found, NULL, NULL); |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3475 retval = gtk_text_iter_get_offset(&found); |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3476 } |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3477 #else |
3 | 3478 if(tmp && GTK_IS_TEXT(tmp)) |
3479 { | |
3480 int len = gtk_text_get_length(GTK_TEXT(tmp)); | |
3481 gchar *tmpbuf; | |
3482 | |
3483 tmpbuf = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), 0, len); | |
3484 if(tmpbuf) | |
3485 { | |
3486 int z, textlen; | |
3487 | |
3488 textlen = strlen(text); | |
3489 | |
3490 if(flags & DW_MLE_CASESENSITIVE) | |
3491 { | |
3492 for(z=point;z<(len-textlen) && !retval;z++) | |
3493 { | |
3494 if(strncmp(&tmpbuf[z], text, textlen) == 0) | |
3495 retval = z + textlen; | |
3496 } | |
3497 } | |
3498 else | |
3499 { | |
3500 for(z=point;z<(len-textlen) && !retval;z++) | |
3501 { | |
3502 if(strncasecmp(&tmpbuf[z], text, textlen) == 0) | |
3503 retval = z + textlen; | |
3504 } | |
3505 } | |
3506 | |
3507 if(retval) | |
3508 { | |
3509 gtk_text_set_point(GTK_TEXT(tmp), retval - textlen); | |
3510 gtk_editable_select_region(&(GTK_TEXT(tmp)->editable), retval - textlen, retval); | |
3511 } | |
3512 | |
3513 g_free(tmpbuf); | |
3514 } | |
3515 } | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3516 #endif |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3517 } |
3 | 3518 DW_MUTEX_UNLOCK; |
3519 return retval; | |
3520 } | |
3521 | |
3522 /* | |
3523 * Stops redrawing of an MLE box. | |
3524 * Parameters: | |
3525 * handle: Handle to the MLE to freeze. | |
3526 */ | |
3527 void dw_mle_freeze(HWND handle) | |
3528 { | |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3529 #if GTK_MAJOR_VERSION < 2 |
3 | 3530 int _locked_by_me = FALSE; |
3531 | |
3532 DW_MUTEX_LOCK; | |
3533 if(GTK_IS_BOX(handle)) | |
3534 { | |
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:
145
diff
changeset
|
3535 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 3536 |
3537 if(tmp && GTK_IS_TEXT(tmp)) | |
3538 { | |
3539 gtk_text_freeze(GTK_TEXT(tmp)); | |
3540 } | |
3541 } | |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3542 DW_MUTEX_UNLOCK; |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3543 #endif |
3 | 3544 } |
3545 | |
3546 /* | |
3547 * Resumes redrawing of an MLE box. | |
3548 * Parameters: | |
3549 * handle: Handle to the MLE to thaw. | |
3550 */ | |
3551 void dw_mle_thaw(HWND handle) | |
3552 { | |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3553 #if GTK_MAJOR_VERSION < 2 |
3 | 3554 int _locked_by_me = FALSE; |
3555 | |
3556 DW_MUTEX_LOCK; | |
3557 if(GTK_IS_BOX(handle)) | |
3558 { | |
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:
145
diff
changeset
|
3559 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 3560 |
3561 if(tmp && GTK_IS_TEXT(tmp)) | |
3562 { | |
3563 gtk_text_thaw(GTK_TEXT(tmp)); | |
3564 } | |
3565 } | |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3566 DW_MUTEX_UNLOCK; |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3567 #endif |
3 | 3568 } |
3569 | |
3570 /* | |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
3571 * Returns the range of the percent bar. |
3 | 3572 * Parameters: |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3573 * handle: Handle to the percent bar to be queried. |
3 | 3574 */ |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
3575 unsigned int dw_percent_query_range(HWND handle) |
3 | 3576 { |
3577 return 100; | |
3578 } | |
3579 | |
3580 /* | |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
3581 * Sets the percent bar position. |
3 | 3582 * Parameters: |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3583 * 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:
60
diff
changeset
|
3584 * position: Position of the percent bar withing the range. |
3 | 3585 */ |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
3586 void dw_percent_set_pos(HWND handle, unsigned int position) |
3 | 3587 { |
3588 int _locked_by_me = FALSE; | |
3589 | |
3590 DW_MUTEX_LOCK; | |
3591 gtk_progress_bar_update(GTK_PROGRESS_BAR(handle), (gfloat)position/100); | |
3592 DW_MUTEX_UNLOCK; | |
3593 } | |
3594 | |
3595 /* | |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3596 * 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:
60
diff
changeset
|
3597 * Parameters: |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3598 * 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:
60
diff
changeset
|
3599 */ |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3600 unsigned int dw_slider_query_pos(HWND handle) |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3601 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3602 int val = 0, _locked_by_me = FALSE; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3603 GtkAdjustment *adjustment; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3604 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3605 if(!handle) |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3606 return 0; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3607 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3608 DW_MUTEX_LOCK; |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
3609 adjustment = (GtkAdjustment *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_adjustment"); |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3610 if(adjustment) |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3611 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3612 int max = _round_value(adjustment->upper) - 1; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3613 int thisval = _round_value(adjustment->value); |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3614 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3615 if(GTK_IS_VSCALE(handle)) |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3616 val = max - thisval; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3617 else |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3618 val = thisval; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3619 } |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3620 DW_MUTEX_UNLOCK; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3621 return val; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3622 } |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3623 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3624 /* |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3625 * Sets the slider position. |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3626 * Parameters: |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3627 * 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:
60
diff
changeset
|
3628 * 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:
60
diff
changeset
|
3629 */ |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3630 void dw_slider_set_pos(HWND handle, unsigned int position) |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3631 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3632 int _locked_by_me = FALSE; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3633 GtkAdjustment *adjustment; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3634 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3635 if(!handle) |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3636 return; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3637 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3638 DW_MUTEX_LOCK; |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
3639 adjustment = (GtkAdjustment *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_adjustment"); |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3640 if(adjustment) |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3641 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3642 int max = _round_value(adjustment->upper) - 1; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3643 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3644 if(GTK_IS_VSCALE(handle)) |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3645 gtk_adjustment_set_value(adjustment, (gfloat)(max - position)); |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3646 else |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3647 gtk_adjustment_set_value(adjustment, (gfloat)position); |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3648 } |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3649 DW_MUTEX_UNLOCK; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3650 } |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3651 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3652 /* |
195
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3653 * Returns the position of the scrollbar. |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3654 * Parameters: |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3655 * handle: Handle to the scrollbar to be queried. |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3656 */ |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3657 unsigned int dw_scrollbar_query_pos(HWND handle) |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3658 { |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3659 int val = 0, _locked_by_me = FALSE; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3660 GtkAdjustment *adjustment; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3661 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3662 if(!handle) |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3663 return 0; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3664 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3665 DW_MUTEX_LOCK; |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
3666 adjustment = (GtkAdjustment *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_adjustment"); |
195
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3667 if(adjustment) |
415
9ffdbfd83652
Don't distinguish between vertical and horizontal scrollbars in
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
410
diff
changeset
|
3668 val = _round_value(adjustment->value); |
195
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3669 DW_MUTEX_UNLOCK; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3670 return val; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3671 } |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3672 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3673 /* |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3674 * Sets the scrollbar position. |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3675 * Parameters: |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3676 * handle: Handle to the scrollbar to be set. |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3677 * position: Position of the scrollbar withing the range. |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3678 */ |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3679 void dw_scrollbar_set_pos(HWND handle, unsigned int position) |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3680 { |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3681 int _locked_by_me = FALSE; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3682 GtkAdjustment *adjustment; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3683 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3684 if(!handle) |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3685 return; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3686 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3687 DW_MUTEX_LOCK; |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
3688 adjustment = (GtkAdjustment *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_adjustment"); |
195
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3689 if(adjustment) |
215
03e68274623d
Two scrollbar fixes for GTK... one from Mark Hessling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
214
diff
changeset
|
3690 gtk_adjustment_set_value(adjustment, (gfloat)position); |
195
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3691 DW_MUTEX_UNLOCK; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3692 } |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3693 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3694 /* |
198
11b5da6196c2
Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
196
diff
changeset
|
3695 * Sets the scrollbar range. |
11b5da6196c2
Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
196
diff
changeset
|
3696 * Parameters: |
11b5da6196c2
Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
196
diff
changeset
|
3697 * handle: Handle to the scrollbar to be set. |
11b5da6196c2
Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
196
diff
changeset
|
3698 * range: Maximum range value. |
205
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
3699 * visible: Visible area relative to the range. |
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
3700 */ |
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
3701 void API dw_scrollbar_set_range(HWND handle, unsigned int range, unsigned int visible) |
198
11b5da6196c2
Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
196
diff
changeset
|
3702 { |
11b5da6196c2
Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
196
diff
changeset
|
3703 int _locked_by_me = FALSE; |
11b5da6196c2
Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
196
diff
changeset
|
3704 GtkAdjustment *adjustment; |
11b5da6196c2
Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
196
diff
changeset
|
3705 |
11b5da6196c2
Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
196
diff
changeset
|
3706 if(!handle) |
11b5da6196c2
Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
196
diff
changeset
|
3707 return; |
11b5da6196c2
Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
196
diff
changeset
|
3708 |
11b5da6196c2
Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
196
diff
changeset
|
3709 DW_MUTEX_LOCK; |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
3710 adjustment = (GtkAdjustment *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_adjustment"); |
198
11b5da6196c2
Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
196
diff
changeset
|
3711 if(adjustment) |
205
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
3712 { |
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
3713 adjustment->upper = (gdouble)range; |
216 | 3714 adjustment->page_increment = adjustment->page_size = (gdouble)visible; |
205
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
3715 } |
198
11b5da6196c2
Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
196
diff
changeset
|
3716 DW_MUTEX_UNLOCK; |
11b5da6196c2
Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
196
diff
changeset
|
3717 } |
11b5da6196c2
Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
196
diff
changeset
|
3718 |
11b5da6196c2
Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
196
diff
changeset
|
3719 /* |
3 | 3720 * Sets the spinbutton value. |
3721 * Parameters: | |
3722 * handle: Handle to the spinbutton to be set. | |
3723 * position: Current value of the spinbutton. | |
3724 */ | |
3725 void dw_spinbutton_set_pos(HWND handle, long position) | |
3726 { | |
3727 int _locked_by_me = FALSE; | |
3728 | |
3729 DW_MUTEX_LOCK; | |
3730 gtk_spin_button_set_value(GTK_SPIN_BUTTON(handle), (gfloat)position); | |
3731 DW_MUTEX_UNLOCK; | |
3732 } | |
3733 | |
3734 /* | |
3735 * Sets the spinbutton limits. | |
3736 * Parameters: | |
3737 * handle: Handle to the spinbutton to be set. | |
3738 * position: Current value of the spinbutton. | |
3739 * position: Current value of the spinbutton. | |
3740 */ | |
3741 void dw_spinbutton_set_limits(HWND handle, long upper, long lower) | |
3742 { | |
3743 long curval; | |
3744 GtkAdjustment *adj; | |
3745 int _locked_by_me = FALSE; | |
3746 | |
3747 curval = dw_spinbutton_query(handle); | |
3748 DW_MUTEX_LOCK; | |
3749 adj = (GtkAdjustment *)gtk_adjustment_new((gfloat)curval, (gfloat)lower, (gfloat)upper, 1.0, 5.0, 0.0); | |
3750 DW_MUTEX_UNLOCK; | |
3751 } | |
3752 | |
3753 /* | |
3754 * Sets the entryfield character limit. | |
3755 * Parameters: | |
3756 * handle: Handle to the spinbutton to be set. | |
3757 * limit: Number of characters the entryfield will take. | |
3758 */ | |
3759 void dw_entryfield_set_limit(HWND handle, ULONG limit) | |
3760 { | |
270
d2a80e648d33
Implemented dw_entryfield_set_limit() on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
269
diff
changeset
|
3761 int _locked_by_me = FALSE; |
d2a80e648d33
Implemented dw_entryfield_set_limit() on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
269
diff
changeset
|
3762 |
d2a80e648d33
Implemented dw_entryfield_set_limit() on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
269
diff
changeset
|
3763 DW_MUTEX_LOCK; |
271
38d8908c4438
Corrected incorrect typecast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
270
diff
changeset
|
3764 gtk_entry_set_max_length(GTK_ENTRY(handle), limit); |
270
d2a80e648d33
Implemented dw_entryfield_set_limit() on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
269
diff
changeset
|
3765 DW_MUTEX_UNLOCK; |
3 | 3766 } |
3767 | |
3768 /* | |
3769 * Returns the current value of the spinbutton. | |
3770 * Parameters: | |
3771 * handle: Handle to the spinbutton to be queried. | |
3772 */ | |
3773 long dw_spinbutton_query(HWND handle) | |
3774 { | |
3775 long retval; | |
3776 int _locked_by_me = FALSE; | |
3777 | |
3778 DW_MUTEX_LOCK; | |
3779 retval = (long)gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(handle)); | |
3780 DW_MUTEX_UNLOCK; | |
3781 | |
3782 return retval; | |
3783 } | |
3784 | |
3785 /* | |
3786 * Returns the state of the checkbox. | |
3787 * Parameters: | |
3788 * handle: Handle to the checkbox to be queried. | |
3789 */ | |
3790 int dw_checkbox_query(HWND handle) | |
3791 { | |
3792 int retval; | |
3793 int _locked_by_me = FALSE; | |
3794 | |
3795 DW_MUTEX_LOCK; | |
3796 retval = GTK_TOGGLE_BUTTON(handle)->active; | |
3797 DW_MUTEX_UNLOCK; | |
3798 | |
3799 return retval; | |
3800 } | |
3801 | |
3802 /* | |
3803 * Sets the state of the checkbox. | |
3804 * Parameters: | |
3805 * handle: Handle to the checkbox to be queried. | |
3806 * value: TRUE for checked, FALSE for unchecked. | |
3807 */ | |
3808 void dw_checkbox_set(HWND handle, int value) | |
3809 { | |
3810 int _locked_by_me = FALSE; | |
3811 | |
3812 DW_MUTEX_LOCK; | |
3813 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(handle), value); | |
3814 DW_MUTEX_UNLOCK; | |
3815 } | |
3816 | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3817 /* |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3818 * 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:
57
diff
changeset
|
3819 * Parameters: |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3820 * handle: Handle to the tree to be inserted. |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3821 * item: Handle to the item to be positioned after. |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3822 * title: The text title of the entry. |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3823 * icon: Handle to coresponding icon. |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3824 * parent: Parent handle or 0 if root. |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3825 * itemdata: Item specific data. |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3826 */ |
329
9b1953ed0bff
Oops missed one parameter change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
328
diff
changeset
|
3827 HTREEITEM 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:
57
diff
changeset
|
3828 { |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3829 #if GTK_MAJOR_VERSION > 1 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3830 GtkWidget *tree; |
140
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
3831 GtkTreeIter *iter; |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3832 GtkTreeStore *store; |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3833 GdkPixbuf *pixbuf; |
328
e00aff2b899e
Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
322
diff
changeset
|
3834 HTREEITEM retval = 0; |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3835 int _locked_by_me = FALSE; |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3836 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3837 if(!handle) |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3838 return NULL; |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3839 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3840 DW_MUTEX_LOCK; |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3841 if((tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle))) |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3842 && GTK_IS_TREE_VIEW(tree) && |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3843 (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store"))) |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3844 { |
140
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
3845 iter = (GtkTreeIter *)malloc(sizeof(GtkTreeIter)); |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
3846 |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3847 pixbuf = _find_pixbuf(icon); |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3848 |
140
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
3849 gtk_tree_store_insert_after(store, iter, (GtkTreeIter *)parent, (GtkTreeIter *)item); |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
3850 gtk_tree_store_set (store, iter, 0, title, 1, pixbuf, 2, itemdata, 3, iter, -1); |
256
63d68387d924
Don't unref a non-existant pixmap. (GTK 2.x)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
255
diff
changeset
|
3851 if(pixbuf) |
63d68387d924
Don't unref a non-existant pixmap. (GTK 2.x)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
255
diff
changeset
|
3852 g_object_unref(pixbuf); |
328
e00aff2b899e
Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
322
diff
changeset
|
3853 retval = (HTREEITEM)iter; |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3854 } |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3855 DW_MUTEX_UNLOCK; |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3856 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3857 return retval; |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3858 #else |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3859 GtkWidget *newitem, *tree, *subtree, *label, *hbox, *pixmap; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3860 GdkPixmap *gdkpix; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3861 GdkBitmap *gdkbmp = NULL; |
107
cd0e5cf92f6a
Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
96
diff
changeset
|
3862 int position = -1; |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3863 int _locked_by_me = FALSE; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3864 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3865 if(!handle) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3866 return NULL; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3867 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3868 DW_MUTEX_LOCK; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3869 tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3870 if(!tree || !GTK_IS_TREE(tree)) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3871 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3872 DW_MUTEX_UNLOCK; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3873 return NULL; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3874 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3875 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3876 if(item && GTK_IS_TREE_ITEM(item)) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3877 position = gtk_tree_child_position(GTK_TREE(tree), item); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3878 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3879 position++; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3880 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3881 newitem = gtk_tree_item_new(); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3882 label = gtk_label_new(title); |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
3883 gtk_object_set_data(GTK_OBJECT(newitem), "_dw_text", (gpointer)strdup(title)); |
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
3884 gtk_object_set_data(GTK_OBJECT(newitem), "_dw_itemdata", (gpointer)itemdata); |
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
3885 gtk_object_set_data(GTK_OBJECT(newitem), "_dw_tree", (gpointer)tree); |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3886 hbox = gtk_hbox_new(FALSE, 2); |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
3887 gtk_object_set_data(GTK_OBJECT(newitem), "_dw_hbox", (gpointer)hbox); |
121
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
3888 gdkpix = _find_pixmap(&gdkbmp, icon, hbox, NULL, NULL); |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3889 gtk_container_add(GTK_CONTAINER(newitem), hbox); |
255
a167001c56df
Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
249
diff
changeset
|
3890 if(gdkpix) |
a167001c56df
Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
249
diff
changeset
|
3891 { |
a167001c56df
Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
249
diff
changeset
|
3892 pixmap = gtk_pixmap_new(gdkpix, gdkbmp); |
a167001c56df
Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
249
diff
changeset
|
3893 gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, TRUE, 0); |
a167001c56df
Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
249
diff
changeset
|
3894 gtk_widget_show(pixmap); |
a167001c56df
Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
249
diff
changeset
|
3895 } |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3896 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, TRUE, 0); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3897 gtk_widget_show(label); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3898 gtk_widget_show(hbox); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3899 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3900 if(parent) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3901 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3902 subtree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(parent)); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3903 if(!subtree) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3904 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
3905 void *thisfunc = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_select_child_func"); |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3906 void *mydata = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_select_child_data"); |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3907 SignalHandler work = _get_signal_handler(tree, mydata); |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3908 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3909 subtree = gtk_tree_new(); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3910 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3911 if(thisfunc && work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3912 { |
409
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
3913 int sigid = _set_signal_handler(subtree, work.window, work.func, work.data, thisfunc); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
3914 gint cid =gtk_signal_connect(GTK_OBJECT(subtree), "select-child", GTK_SIGNAL_FUNC(thisfunc),(gpointer)sigid); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
3915 _set_signal_handler_id(subtree, sigid, cid); |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3916 } |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3917 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
3918 thisfunc = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_container_context_func"); |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3919 mydata = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_container_context_data"); |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3920 work = _get_signal_handler(tree, mydata); |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3921 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3922 if(thisfunc && work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3923 { |
409
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
3924 int sigid = _set_signal_handler(subtree, work.window, work.func, work.data, thisfunc); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
3925 gint cid =gtk_signal_connect(GTK_OBJECT(subtree), "button_press_event", GTK_SIGNAL_FUNC(thisfunc),(gpointer)sigid); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
3926 _set_signal_handler_id(subtree, sigid, cid); |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3927 } |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3928 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3929 gtk_object_set_user_data(GTK_OBJECT(parent), subtree); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3930 gtk_tree_set_selection_mode(GTK_TREE(subtree), GTK_SELECTION_SINGLE); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3931 gtk_tree_set_view_mode(GTK_TREE(subtree), GTK_TREE_VIEW_ITEM); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3932 gtk_tree_item_set_subtree(GTK_TREE_ITEM(parent), subtree); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3933 gtk_tree_item_collapse(GTK_TREE_ITEM(parent)); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3934 gtk_widget_show(subtree); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3935 gtk_tree_item_expand(GTK_TREE_ITEM(parent)); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3936 gtk_tree_item_collapse(GTK_TREE_ITEM(parent)); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3937 } |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
3938 gtk_object_set_data(GTK_OBJECT(newitem), "_dw_parenttree", (gpointer)subtree); |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3939 gtk_tree_insert(GTK_TREE(subtree), newitem, position); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3940 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3941 else |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3942 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
3943 gtk_object_set_data(GTK_OBJECT(newitem), "_dw_parenttree", (gpointer)tree); |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3944 gtk_tree_insert(GTK_TREE(tree), newitem, position); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3945 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3946 gtk_tree_item_expand(GTK_TREE_ITEM(newitem)); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3947 gtk_tree_item_collapse(GTK_TREE_ITEM(newitem)); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3948 gtk_widget_show(newitem); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3949 DW_MUTEX_UNLOCK; |
328
e00aff2b899e
Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
322
diff
changeset
|
3950 return (HTREEITEM)newitem; |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3951 #endif |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3952 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3953 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3954 /* |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3955 * 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:
19
diff
changeset
|
3956 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3957 * 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:
19
diff
changeset
|
3958 * 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:
19
diff
changeset
|
3959 * 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:
19
diff
changeset
|
3960 * 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
|
3961 * itemdata: Item specific data. |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3962 */ |
328
e00aff2b899e
Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
322
diff
changeset
|
3963 HTREEITEM 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:
19
diff
changeset
|
3964 { |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3965 #if GTK_MAJOR_VERSION > 1 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3966 GtkWidget *tree; |
140
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
3967 GtkTreeIter *iter; |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3968 GtkTreeStore *store; |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3969 GdkPixbuf *pixbuf; |
328
e00aff2b899e
Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
322
diff
changeset
|
3970 HTREEITEM retval = 0; |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3971 int _locked_by_me = FALSE; |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3972 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3973 if(!handle) |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3974 return NULL; |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3975 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3976 DW_MUTEX_LOCK; |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3977 if((tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle))) |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3978 && GTK_IS_TREE_VIEW(tree) && |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3979 (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store"))) |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3980 { |
140
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
3981 iter = (GtkTreeIter *)malloc(sizeof(GtkTreeIter)); |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
3982 |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3983 pixbuf = _find_pixbuf(icon); |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3984 |
140
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
3985 gtk_tree_store_append (store, iter, (GtkTreeIter *)parent); |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
3986 gtk_tree_store_set (store, iter, 0, title, 1, pixbuf, 2, itemdata, 3, iter, -1); |
256
63d68387d924
Don't unref a non-existant pixmap. (GTK 2.x)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
255
diff
changeset
|
3987 if(pixbuf) |
63d68387d924
Don't unref a non-existant pixmap. (GTK 2.x)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
255
diff
changeset
|
3988 g_object_unref(pixbuf); |
328
e00aff2b899e
Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
322
diff
changeset
|
3989 retval = (HTREEITEM)iter; |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3990 } |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3991 DW_MUTEX_UNLOCK; |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3992 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3993 return retval; |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3994 #else |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3995 GtkWidget *item, *tree, *subtree, *label, *hbox, *pixmap; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3996 GdkPixmap *gdkpix; |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3997 GdkBitmap *gdkbmp = NULL; |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3998 int _locked_by_me = FALSE; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3999 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4000 if(!handle) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4001 return NULL; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4002 |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4003 DW_MUTEX_LOCK; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4004 tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4005 if(!tree || !GTK_IS_TREE(tree)) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4006 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4007 DW_MUTEX_UNLOCK; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4008 return NULL; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4009 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4010 item = gtk_tree_item_new(); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4011 label = gtk_label_new(title); |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4012 gtk_object_set_data(GTK_OBJECT(item), "_dw_text", (gpointer)strdup(title)); |
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4013 gtk_object_set_data(GTK_OBJECT(item), "_dw_itemdata", (gpointer)itemdata); |
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4014 gtk_object_set_data(GTK_OBJECT(item), "_dw_tree", (gpointer)tree); |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4015 hbox = gtk_hbox_new(FALSE, 2); |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4016 gtk_object_set_data(GTK_OBJECT(item), "_dw_hbox", (gpointer)hbox); |
121
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
4017 gdkpix = _find_pixmap(&gdkbmp, icon, hbox, NULL, NULL); |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4018 gtk_container_add(GTK_CONTAINER(item), hbox); |
255
a167001c56df
Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
249
diff
changeset
|
4019 if(gdkpix) |
a167001c56df
Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
249
diff
changeset
|
4020 { |
a167001c56df
Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
249
diff
changeset
|
4021 pixmap = gtk_pixmap_new(gdkpix, gdkbmp); |
a167001c56df
Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
249
diff
changeset
|
4022 gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, TRUE, 0); |
a167001c56df
Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
249
diff
changeset
|
4023 gtk_widget_show(pixmap); |
a167001c56df
Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
249
diff
changeset
|
4024 } |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4025 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, TRUE, 0); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4026 gtk_widget_show(label); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4027 gtk_widget_show(hbox); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4028 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4029 if(parent) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4030 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4031 subtree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(parent)); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4032 if(!subtree) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4033 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4034 void *thisfunc = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_select_child_func"); |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
4035 void *mydata = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_select_child_data"); |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
4036 SignalHandler work = _get_signal_handler(tree, mydata); |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4037 |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4038 subtree = gtk_tree_new(); |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4039 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
4040 if(thisfunc && work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
4041 { |
409
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
4042 int sigid = _set_signal_handler(subtree, work.window, work.func, work.data, thisfunc); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
4043 gint cid =gtk_signal_connect(GTK_OBJECT(subtree), "select-child", GTK_SIGNAL_FUNC(thisfunc),(gpointer)sigid); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
4044 _set_signal_handler_id(subtree, sigid, cid); |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
4045 } |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4046 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4047 thisfunc = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_container_context_func"); |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
4048 mydata = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_container_context_data"); |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
4049 work = _get_signal_handler(tree, mydata); |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
4050 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
4051 if(thisfunc && work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
4052 { |
409
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
4053 int sigid = _set_signal_handler(subtree, work.window, work.func, work.data, thisfunc); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
4054 gint cid =gtk_signal_connect(GTK_OBJECT(subtree), "button_press_event", GTK_SIGNAL_FUNC(thisfunc),(gpointer)sigid); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
4055 _set_signal_handler_id(subtree, sigid, cid); |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
4056 } |
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
|
4057 |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4058 gtk_object_set_user_data(GTK_OBJECT(parent), subtree); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4059 gtk_tree_set_selection_mode(GTK_TREE(subtree), GTK_SELECTION_SINGLE); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4060 gtk_tree_set_view_mode(GTK_TREE(subtree), GTK_TREE_VIEW_ITEM); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4061 gtk_tree_item_set_subtree(GTK_TREE_ITEM(parent), subtree); |
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
|
4062 gtk_tree_item_collapse(GTK_TREE_ITEM(parent)); |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4063 gtk_widget_show(subtree); |
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
|
4064 gtk_tree_item_expand(GTK_TREE_ITEM(parent)); |
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
|
4065 gtk_tree_item_collapse(GTK_TREE_ITEM(parent)); |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4066 } |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4067 gtk_object_set_data(GTK_OBJECT(item), "_dw_parenttree", (gpointer)subtree); |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4068 gtk_tree_append(GTK_TREE(subtree), item); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4069 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4070 else |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4071 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4072 gtk_object_set_data(GTK_OBJECT(item), "_dw_parenttree", (gpointer)tree); |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4073 gtk_tree_append(GTK_TREE(tree), item); |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4074 } |
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
|
4075 gtk_tree_item_expand(GTK_TREE_ITEM(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
|
4076 gtk_tree_item_collapse(GTK_TREE_ITEM(item)); |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4077 gtk_widget_show(item); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4078 DW_MUTEX_UNLOCK; |
328
e00aff2b899e
Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
322
diff
changeset
|
4079 return (HTREEITEM)item; |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4080 #endif |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4081 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4082 |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4083 /* |
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
|
4084 * 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
|
4085 * 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
|
4086 * 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
|
4087 * 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
|
4088 * 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
|
4089 * 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
|
4090 */ |
328
e00aff2b899e
Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
322
diff
changeset
|
4091 void 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
|
4092 { |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4093 #if GTK_MAJOR_VERSION > 1 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4094 GtkWidget *tree; |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4095 GtkTreeStore *store; |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4096 GdkPixbuf *pixbuf; |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4097 int _locked_by_me = FALSE; |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4098 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4099 if(!handle) |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4100 return; |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4101 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4102 DW_MUTEX_LOCK; |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4103 if((tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle))) |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4104 && GTK_IS_TREE_VIEW(tree) && |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4105 (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store"))) |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4106 { |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4107 pixbuf = _find_pixbuf(icon); |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4108 |
139
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4109 gtk_tree_store_set(store, (GtkTreeIter *)item, 0, title, 1, pixbuf, -1); |
256
63d68387d924
Don't unref a non-existant pixmap. (GTK 2.x)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
255
diff
changeset
|
4110 if(pixbuf) |
63d68387d924
Don't unref a non-existant pixmap. (GTK 2.x)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
255
diff
changeset
|
4111 g_object_unref(pixbuf); |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4112 } |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4113 DW_MUTEX_UNLOCK; |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4114 #else |
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
|
4115 GtkWidget *label, *hbox, *pixmap; |
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
|
4116 GdkPixmap *gdkpix; |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4117 GdkBitmap *gdkbmp = NULL; |
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
|
4118 char *oldtext; |
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
|
4119 int _locked_by_me = FALSE; |
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
|
4120 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4121 if(!handle || !item) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4122 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4123 |
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
|
4124 DW_MUTEX_LOCK; |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4125 oldtext = (char *)gtk_object_get_data(GTK_OBJECT(item), "_dw_text"); |
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
|
4126 if(oldtext) |
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
|
4127 free(oldtext); |
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
|
4128 label = gtk_label_new(title); |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4129 gtk_object_set_data(GTK_OBJECT(item), "_dw_text", (gpointer)strdup(title)); |
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4130 hbox = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(item), "_dw_hbox"); |
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
|
4131 gtk_widget_destroy(hbox); |
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
|
4132 hbox = gtk_hbox_new(FALSE, 2); |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4133 gtk_object_set_data(GTK_OBJECT(item), "_dw_hbox", (gpointer)hbox); |
121
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
4134 gdkpix = _find_pixmap(&gdkbmp, icon, hbox, NULL, NULL); |
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
|
4135 gtk_container_add(GTK_CONTAINER(item), hbox); |
255
a167001c56df
Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
249
diff
changeset
|
4136 if(gdkpix) |
a167001c56df
Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
249
diff
changeset
|
4137 { |
a167001c56df
Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
249
diff
changeset
|
4138 pixmap = gtk_pixmap_new(gdkpix, gdkbmp); |
a167001c56df
Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
249
diff
changeset
|
4139 gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, TRUE, 0); |
a167001c56df
Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
249
diff
changeset
|
4140 gtk_widget_show(pixmap); |
a167001c56df
Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
249
diff
changeset
|
4141 } |
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
|
4142 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, TRUE, 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
|
4143 gtk_widget_show(label); |
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
|
4144 gtk_widget_show(hbox); |
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
|
4145 DW_MUTEX_UNLOCK; |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4146 #endif |
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
|
4147 } |
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
|
4148 |
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
|
4149 /* |
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
|
4150 * 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
|
4151 * 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
|
4152 * 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
|
4153 * 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
|
4154 * 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
|
4155 */ |
328
e00aff2b899e
Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
322
diff
changeset
|
4156 void 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
|
4157 { |
140
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
4158 #if GTK_MAJOR_VERSION > 1 |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
4159 GtkWidget *tree; |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
4160 GtkTreeStore *store; |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
4161 int _locked_by_me = FALSE; |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
4162 |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
4163 if(!handle || !item) |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
4164 return; |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
4165 |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
4166 DW_MUTEX_LOCK; |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
4167 if((tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle))) |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
4168 && GTK_IS_TREE_VIEW(tree) && |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
4169 (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store"))) |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
4170 gtk_tree_store_set(store, (GtkTreeIter *)item, 2, itemdata, -1); |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
4171 DW_MUTEX_UNLOCK; |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
4172 #else |
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
|
4173 int _locked_by_me = FALSE; |
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
|
4174 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4175 if(!handle || !item) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4176 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4177 |
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
|
4178 DW_MUTEX_LOCK; |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4179 gtk_object_set_data(GTK_OBJECT(item), "_dw_itemdata", (gpointer)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
|
4180 DW_MUTEX_UNLOCK; |
140
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
4181 #endif |
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
|
4182 } |
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
|
4183 |
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
|
4184 /* |
317
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4185 * 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:
316
diff
changeset
|
4186 * Parameters: |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4187 * 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:
316
diff
changeset
|
4188 * 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:
316
diff
changeset
|
4189 */ |
328
e00aff2b899e
Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
322
diff
changeset
|
4190 void *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:
316
diff
changeset
|
4191 { |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4192 void *ret = NULL; |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4193 #if GTK_MAJOR_VERSION > 1 |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4194 GtkWidget *tree; |
322
78be9770960c
Oops, used wrong type in GTK 2.x dw_tree_get_data(), thanks Mark.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
320
diff
changeset
|
4195 GtkTreeModel *store; |
317
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4196 int _locked_by_me = FALSE; |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4197 |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4198 if(!handle || !item) |
319
aed5d742896d
Fixed errant returns on failure.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
317
diff
changeset
|
4199 return NULL; |
317
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4200 |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4201 DW_MUTEX_LOCK; |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4202 if((tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle))) |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4203 && GTK_IS_TREE_VIEW(tree) && |
322
78be9770960c
Oops, used wrong type in GTK 2.x dw_tree_get_data(), thanks Mark.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
320
diff
changeset
|
4204 (store = (GtkTreeModel *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store"))) |
317
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4205 gtk_tree_model_get(store, (GtkTreeIter *)item, 2, &ret, -1); |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4206 DW_MUTEX_UNLOCK; |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4207 #else |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4208 int _locked_by_me = FALSE; |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4209 |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4210 if(!handle || !item) |
319
aed5d742896d
Fixed errant returns on failure.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
317
diff
changeset
|
4211 return NULL; |
317
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4212 |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4213 DW_MUTEX_LOCK; |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4214 ret = (void *)gtk_object_get_data(GTK_OBJECT(item), "_dw_itemdata"); |
317
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4215 DW_MUTEX_UNLOCK; |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4216 #endif |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4217 return ret; |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4218 } |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4219 |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4220 /* |
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
|
4221 * 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
|
4222 * 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
|
4223 * 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
|
4224 * 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
|
4225 */ |
328
e00aff2b899e
Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
322
diff
changeset
|
4226 void 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
|
4227 { |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4228 #if GTK_MAJOR_VERSION > 1 |
139
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4229 GtkWidget *tree; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4230 GtkTreeStore *store; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4231 int _locked_by_me = FALSE; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4232 |
141
36dc19aa7773
Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
140
diff
changeset
|
4233 if(!handle || !item) |
139
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4234 return; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4235 |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4236 DW_MUTEX_LOCK; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4237 if((tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle))) |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4238 && GTK_IS_TREE_VIEW(tree) && |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4239 (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store"))) |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4240 { |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4241 GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), (GtkTreeIter *)item); |
140
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
4242 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
4243 |
139
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4244 gtk_tree_view_set_cursor(GTK_TREE_VIEW(tree), path, NULL, FALSE); |
140
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
4245 gtk_tree_selection_select_iter(sel, (GtkTreeIter *)item); |
139
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4246 gtk_tree_path_free(path); |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4247 } |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4248 DW_MUTEX_UNLOCK; |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4249 #else |
107
cd0e5cf92f6a
Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
96
diff
changeset
|
4250 GtkWidget *lastselect, *tree; |
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
|
4251 int _locked_by_me = FALSE; |
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
|
4252 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4253 if(!handle || !item) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4254 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4255 |
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
|
4256 DW_MUTEX_LOCK; |
107
cd0e5cf92f6a
Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
96
diff
changeset
|
4257 tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4258 lastselect = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_lastselect"); |
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
|
4259 if(lastselect && GTK_IS_TREE_ITEM(lastselect)) |
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
|
4260 gtk_tree_item_deselect(GTK_TREE_ITEM(lastselect)); |
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
|
4261 gtk_tree_item_select(GTK_TREE_ITEM(item)); |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4262 gtk_object_set_data(GTK_OBJECT(tree), "_dw_lastselect", (gpointer)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
|
4263 DW_MUTEX_UNLOCK; |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4264 #endif |
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
|
4265 } |
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
|
4266 |
143
1d57c27e4adc
Moved _dw_recursive_free into GTK 2.0 #ifdefs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
142
diff
changeset
|
4267 #if GTK_MAJOR_VERSION > 1 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4268 static void _dw_recursive_free(GtkTreeModel *store, GtkTreeIter parent) |
141
36dc19aa7773
Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
140
diff
changeset
|
4269 { |
36dc19aa7773
Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
140
diff
changeset
|
4270 void *data; |
36dc19aa7773
Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
140
diff
changeset
|
4271 GtkTreeIter iter; |
36dc19aa7773
Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
140
diff
changeset
|
4272 |
36dc19aa7773
Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
140
diff
changeset
|
4273 gtk_tree_model_get(store, &parent, 3, &data, -1); |
36dc19aa7773
Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
140
diff
changeset
|
4274 if(data) |
36dc19aa7773
Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
140
diff
changeset
|
4275 free(data); |
36dc19aa7773
Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
140
diff
changeset
|
4276 gtk_tree_store_set(GTK_TREE_STORE(store), &parent, 3, NULL, -1); |
36dc19aa7773
Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
140
diff
changeset
|
4277 |
36dc19aa7773
Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
140
diff
changeset
|
4278 if(gtk_tree_model_iter_children(store, &iter, &parent)) |
36dc19aa7773
Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
140
diff
changeset
|
4279 { |
36dc19aa7773
Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
140
diff
changeset
|
4280 do { |
36dc19aa7773
Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
140
diff
changeset
|
4281 _dw_recursive_free(GTK_TREE_MODEL(store), iter); |
36dc19aa7773
Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
140
diff
changeset
|
4282 } while(gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter)); |
36dc19aa7773
Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
140
diff
changeset
|
4283 } |
36dc19aa7773
Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
140
diff
changeset
|
4284 } |
143
1d57c27e4adc
Moved _dw_recursive_free into GTK 2.0 #ifdefs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
142
diff
changeset
|
4285 #endif |
141
36dc19aa7773
Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
140
diff
changeset
|
4286 |
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
|
4287 /* |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4288 * Removes all nodes from a tree. |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4289 * Parameters: |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4290 * 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
|
4291 */ |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4292 void dw_tree_clear(HWND handle) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4293 { |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4294 #if GTK_MAJOR_VERSION > 1 |
141
36dc19aa7773
Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
140
diff
changeset
|
4295 GtkWidget *tree; |
139
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4296 GtkTreeStore *store; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4297 int _locked_by_me = FALSE; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4298 |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4299 if(!handle) |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4300 return; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4301 |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4302 DW_MUTEX_LOCK; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4303 if((tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle))) |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4304 && GTK_IS_TREE_VIEW(tree) && |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4305 (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store"))) |
141
36dc19aa7773
Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
140
diff
changeset
|
4306 { |
36dc19aa7773
Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
140
diff
changeset
|
4307 GtkTreeIter iter; |
36dc19aa7773
Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
140
diff
changeset
|
4308 |
36dc19aa7773
Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
140
diff
changeset
|
4309 if(gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter)) |
36dc19aa7773
Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
140
diff
changeset
|
4310 { |
36dc19aa7773
Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
140
diff
changeset
|
4311 do { |
36dc19aa7773
Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
140
diff
changeset
|
4312 _dw_recursive_free(GTK_TREE_MODEL(store), iter); |
36dc19aa7773
Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
140
diff
changeset
|
4313 } while(gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter)); |
36dc19aa7773
Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
140
diff
changeset
|
4314 } |
139
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4315 gtk_tree_store_clear(store); |
141
36dc19aa7773
Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
140
diff
changeset
|
4316 } |
139
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4317 DW_MUTEX_UNLOCK; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4318 #else |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4319 GtkWidget *tree; |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4320 int _locked_by_me = FALSE; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4321 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4322 if(!handle) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4323 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4324 |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4325 DW_MUTEX_LOCK; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4326 tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4327 if(!tree || !GTK_IS_TREE(tree)) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4328 { |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4329 DW_MUTEX_UNLOCK; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4330 return; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4331 } |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4332 gtk_object_set_data(GTK_OBJECT(tree), "_dw_lastselect", NULL); |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4333 gtk_tree_clear_items(GTK_TREE(tree), 0, 1000000); |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4334 DW_MUTEX_UNLOCK; |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4335 #endif |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4336 } |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4337 |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4338 /* |
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
|
4339 * 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
|
4340 * 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
|
4341 * 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
|
4342 * 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
|
4343 */ |
328
e00aff2b899e
Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
322
diff
changeset
|
4344 void dw_tree_expand(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
|
4345 { |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4346 #if GTK_MAJOR_VERSION > 1 |
139
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4347 GtkWidget *tree; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4348 GtkTreeStore *store; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4349 int _locked_by_me = FALSE; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4350 |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4351 if(!handle) |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4352 return; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4353 |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4354 DW_MUTEX_LOCK; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4355 if((tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle))) |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4356 && GTK_IS_TREE_VIEW(tree) && |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4357 (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store"))) |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4358 { |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4359 GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), (GtkTreeIter *)item); |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4360 gtk_tree_view_expand_row(GTK_TREE_VIEW(tree), path, FALSE); |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4361 gtk_tree_path_free(path); |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4362 } |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4363 DW_MUTEX_UNLOCK; |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4364 #else |
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
|
4365 int _locked_by_me = FALSE; |
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
|
4366 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4367 if(!handle || !item) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4368 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4369 |
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
|
4370 DW_MUTEX_LOCK; |
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
|
4371 if(GTK_IS_TREE_ITEM(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
|
4372 gtk_tree_item_expand(GTK_TREE_ITEM(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
|
4373 DW_MUTEX_UNLOCK; |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4374 #endif |
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
|
4375 } |
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
|
4376 |
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
|
4377 /* |
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
|
4378 * 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
|
4379 * 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
|
4380 * 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
|
4381 * 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
|
4382 */ |
328
e00aff2b899e
Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
322
diff
changeset
|
4383 void dw_tree_collapse(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
|
4384 { |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4385 #if GTK_MAJOR_VERSION > 1 |
139
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4386 GtkWidget *tree; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4387 GtkTreeStore *store; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4388 int _locked_by_me = FALSE; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4389 |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4390 if(!handle) |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4391 return; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4392 |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4393 DW_MUTEX_LOCK; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4394 if((tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle))) |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4395 && GTK_IS_TREE_VIEW(tree) && |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4396 (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store"))) |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4397 { |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4398 GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), (GtkTreeIter *)item); |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4399 gtk_tree_view_collapse_row(GTK_TREE_VIEW(tree), path); |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4400 gtk_tree_path_free(path); |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4401 } |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4402 DW_MUTEX_UNLOCK; |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4403 #else |
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
|
4404 int _locked_by_me = FALSE; |
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
|
4405 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4406 if(!handle || !item) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4407 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4408 |
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
|
4409 DW_MUTEX_LOCK; |
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
|
4410 if(GTK_IS_TREE_ITEM(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
|
4411 gtk_tree_item_collapse(GTK_TREE_ITEM(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
|
4412 DW_MUTEX_UNLOCK; |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4413 #endif |
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
|
4414 } |
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
|
4415 |
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
|
4416 /* |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4417 * Removes a node from a tree. |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4418 * Parameters: |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4419 * 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
|
4420 * item: Handle to node to be deleted. |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4421 */ |
328
e00aff2b899e
Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
322
diff
changeset
|
4422 void 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
|
4423 { |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4424 #if GTK_MAJOR_VERSION > 1 |
139
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4425 GtkWidget *tree; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4426 GtkTreeStore *store; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4427 int _locked_by_me = FALSE; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4428 |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4429 if(!handle) |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4430 return; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4431 |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4432 DW_MUTEX_LOCK; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4433 if((tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle))) |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4434 && GTK_IS_TREE_VIEW(tree) && |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4435 (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store"))) |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4436 { |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4437 gtk_tree_store_remove(store, (GtkTreeIter *)item); |
140
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
4438 free(item); |
139
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4439 } |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4440 DW_MUTEX_UNLOCK; |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4441 #else |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4442 GtkWidget *tree, *lastselect, *parenttree; |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4443 int _locked_by_me = FALSE; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4444 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4445 if(!handle || !item || !GTK_IS_WIDGET(handle) || !GTK_IS_WIDGET(item)) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4446 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4447 |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4448 DW_MUTEX_LOCK; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4449 tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4450 if(!tree || !GTK_IS_TREE(tree)) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4451 { |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4452 DW_MUTEX_UNLOCK; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4453 return; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4454 } |
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
|
4455 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4456 lastselect = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_lastselect"); |
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4457 |
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4458 parenttree = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(item), "_dw_parenttree"); |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4459 |
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
|
4460 if(lastselect == item) |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4461 { |
107
cd0e5cf92f6a
Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
96
diff
changeset
|
4462 gtk_tree_item_deselect(GTK_TREE_ITEM(lastselect)); |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4463 gtk_object_set_data(GTK_OBJECT(tree), "_dw_lastselect", NULL); |
107
cd0e5cf92f6a
Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
96
diff
changeset
|
4464 } |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4465 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4466 if(parenttree && GTK_IS_WIDGET(parenttree)) |
107
cd0e5cf92f6a
Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
96
diff
changeset
|
4467 gtk_container_remove(GTK_CONTAINER(parenttree), item); |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4468 DW_MUTEX_UNLOCK; |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4469 #endif |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4470 } |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4471 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4472 static int _dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator, int extra) |
3 | 4473 { |
4474 GtkWidget *clist; | |
4475 char numbuf[10]; | |
350
2216e65ad2ae
Removed slider flags and container selection flags from the header file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
346
diff
changeset
|
4476 int z, multi; |
3 | 4477 int _locked_by_me = FALSE; |
355
3a71623fc219
Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
354
diff
changeset
|
4478 GtkJustification justification; |
3 | 4479 |
4480 DW_MUTEX_LOCK; | |
4481 clist = gtk_clist_new_with_titles(count, (gchar **)titles); | |
4482 if(!clist) | |
4483 { | |
4484 DW_MUTEX_UNLOCK; | |
4485 return FALSE; | |
4486 } | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4487 multi = (int)gtk_object_get_data(GTK_OBJECT(handle), "_dw_multi"); |
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4488 gtk_object_set_data(GTK_OBJECT(handle), "_dw_multi", (gpointer)multi); |
3 | 4489 |
4490 gtk_clist_set_column_auto_resize(GTK_CLIST(clist), 0, TRUE); | |
350
2216e65ad2ae
Removed slider flags and container selection flags from the header file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
346
diff
changeset
|
4491 if(multi) |
2216e65ad2ae
Removed slider flags and container selection flags from the header file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
346
diff
changeset
|
4492 gtk_clist_set_selection_mode(GTK_CLIST(clist), GTK_SELECTION_EXTENDED); |
2216e65ad2ae
Removed slider flags and container selection flags from the header file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
346
diff
changeset
|
4493 else |
2216e65ad2ae
Removed slider flags and container selection flags from the header file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
346
diff
changeset
|
4494 gtk_clist_set_selection_mode(GTK_CLIST(clist), GTK_SELECTION_SINGLE); |
3 | 4495 gtk_container_add(GTK_CONTAINER(handle), clist); |
4496 gtk_object_set_user_data(GTK_OBJECT(handle), (gpointer)clist); | |
4497 gtk_widget_show(clist); | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4498 gtk_object_set_data(GTK_OBJECT(clist), "_dw_colcount", (gpointer)count); |
3 | 4499 |
4500 if(extra) | |
4501 gtk_clist_set_column_width(GTK_CLIST(clist), 1, 120); | |
4502 | |
4503 for(z=0;z<count;z++) | |
4504 { | |
4505 if(!extra || z > 1) | |
4506 gtk_clist_set_column_width(GTK_CLIST(clist), z, 50); | |
4507 sprintf(numbuf, "%d", z); | |
4508 gtk_object_set_data(GTK_OBJECT(clist), numbuf, (gpointer)flags[z]); | |
355
3a71623fc219
Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
354
diff
changeset
|
4509 if(flags[z]&DW_CFA_RIGHT) |
3a71623fc219
Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
354
diff
changeset
|
4510 justification = GTK_JUSTIFY_RIGHT; |
3a71623fc219
Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
354
diff
changeset
|
4511 else if(flags[z]&DW_CFA_CENTER) |
3a71623fc219
Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
354
diff
changeset
|
4512 justification = GTK_JUSTIFY_CENTER; |
3a71623fc219
Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
354
diff
changeset
|
4513 else |
3a71623fc219
Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
354
diff
changeset
|
4514 justification = GTK_JUSTIFY_LEFT; |
3a71623fc219
Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
354
diff
changeset
|
4515 gtk_clist_set_column_justification(GTK_CLIST(clist),z,justification); |
3 | 4516 } |
4517 | |
4518 DW_MUTEX_UNLOCK; | |
4519 return TRUE; | |
4520 } | |
4521 | |
4522 /* | |
4523 * Sets up the container columns. | |
4524 * Parameters: | |
4525 * handle: Handle to the container to be configured. | |
4526 * flags: An array of unsigned longs with column flags. | |
4527 * titles: An array of strings with column text titles. | |
4528 * count: The number of columns (this should match the arrays). | |
4529 * separator: The column number that contains the main separator. | |
4530 * (this item may only be used in OS/2) | |
4531 */ | |
4532 int dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator) | |
4533 { | |
4534 return _dw_container_setup(handle, flags, titles, count, separator, 0); | |
4535 } | |
4536 | |
4537 /* | |
4538 * Sets up the filesystem columns, note: filesystem always has an icon/filename field. | |
4539 * Parameters: | |
4540 * handle: Handle to the container to be configured. | |
4541 * flags: An array of unsigned longs with column flags. | |
4542 * titles: An array of strings with column text titles. | |
4543 * count: The number of columns (this should match the arrays). | |
4544 */ | |
4545 int dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count) | |
4546 { | |
4547 char **newtitles = malloc(sizeof(char *) * (count + 2)); | |
4548 unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 2)); | |
4549 | |
4550 newtitles[0] = "Icon"; | |
4551 newtitles[1] = "Filename"; | |
4552 | |
4553 newflags[0] = DW_CFA_BITMAPORICON | DW_CFA_CENTER | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR; | |
4554 newflags[1] = DW_CFA_STRING | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR; | |
4555 | |
4556 memcpy(&newtitles[2], titles, sizeof(char *) * count); | |
4557 memcpy(&newflags[2], flags, sizeof(unsigned long) * count); | |
4558 | |
4559 _dw_container_setup(handle, newflags, newtitles, count + 2, 2, 1); | |
4560 | |
4561 free(newtitles); | |
4562 free(newflags); | |
4563 return TRUE; | |
4564 } | |
4565 | |
4566 /* | |
4567 * Obtains an icon from a module (or header in GTK). | |
4568 * Parameters: | |
4569 * module: Handle to module (DLL) in OS/2 and Windows. | |
4570 * id: A unsigned long id int the resources on OS/2 and | |
4571 * Windows, on GTK this is converted to a pointer | |
4572 * to an embedded XPM. | |
4573 */ | |
4574 unsigned long dw_icon_load(unsigned long module, unsigned long id) | |
4575 { | |
4576 return id; | |
4577 } | |
4578 | |
4579 /* | |
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:
256
diff
changeset
|
4580 * 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:
256
diff
changeset
|
4581 * 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:
256
diff
changeset
|
4582 * 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:
256
diff
changeset
|
4583 * 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:
256
diff
changeset
|
4584 * (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:
256
diff
changeset
|
4585 */ |
9ea4ac9a097f
Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
256
diff
changeset
|
4586 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:
256
diff
changeset
|
4587 { |
265
84471d53ab58
Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
264
diff
changeset
|
4588 int found = -1, _locked_by_me = FALSE; |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4589 #if GTK_MAJOR_VERSION > 1 |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4590 GdkPixbuf *pixbuf; |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4591 #elif defined(USE_IMLIB) |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4592 GdkImlibImage *image; |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4593 #endif |
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:
256
diff
changeset
|
4594 char *file = alloca(strlen(filename) + 5); |
265
84471d53ab58
Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
264
diff
changeset
|
4595 unsigned long z, ret = 0; |
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:
256
diff
changeset
|
4596 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4597 if (!file) |
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:
256
diff
changeset
|
4598 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:
256
diff
changeset
|
4599 |
9ea4ac9a097f
Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
256
diff
changeset
|
4600 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:
256
diff
changeset
|
4601 |
9ea4ac9a097f
Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
256
diff
changeset
|
4602 /* 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:
256
diff
changeset
|
4603 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:
256
diff
changeset
|
4604 { |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4605 /* Try with .xpm extention */ |
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:
256
diff
changeset
|
4606 strcat(file, ".xpm"); |
9ea4ac9a097f
Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
256
diff
changeset
|
4607 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:
256
diff
changeset
|
4608 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:
256
diff
changeset
|
4609 } |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4610 |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4611 DW_MUTEX_LOCK; |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4612 /* Find a free entry in the array */ |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4613 for(z=0;z<_PixmapCount;z++) |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4614 { |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4615 if(!_PixmapArray[z].used) |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4616 { |
265
84471d53ab58
Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
264
diff
changeset
|
4617 ret = found = z; |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4618 break; |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4619 } |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4620 } |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4621 |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4622 /* If there are no free entries, expand the |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4623 * array. |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4624 */ |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4625 if(found == -1) |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4626 { |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4627 DWPrivatePixmap *old = _PixmapArray; |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4628 |
265
84471d53ab58
Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
264
diff
changeset
|
4629 ret = found = _PixmapCount; |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4630 _PixmapCount++; |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4631 |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4632 _PixmapArray = malloc(sizeof(DWPrivatePixmap) * _PixmapCount); |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4633 |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4634 if(found) |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4635 memcpy(_PixmapArray, old, sizeof(DWPrivatePixmap) * found); |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4636 if(old) |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4637 free(old); |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4638 _PixmapArray[found].used = 1; |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4639 _PixmapArray[found].pixmap = _PixmapArray[found].mask = NULL; |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4640 } |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4641 |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4642 #if GTK_MAJOR_VERSION > 1 |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4643 pixbuf = gdk_pixbuf_new_from_file(file, NULL); |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4644 |
265
84471d53ab58
Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
264
diff
changeset
|
4645 if(pixbuf) |
84471d53ab58
Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
264
diff
changeset
|
4646 { |
316
a07e08f708d6
Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
312
diff
changeset
|
4647 _PixmapArray[found].pixbuf = pixbuf; |
265
84471d53ab58
Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
264
diff
changeset
|
4648 _PixmapArray[found].width = gdk_pixbuf_get_width(pixbuf); |
84471d53ab58
Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
264
diff
changeset
|
4649 _PixmapArray[found].height = gdk_pixbuf_get_height(pixbuf); |
84471d53ab58
Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
264
diff
changeset
|
4650 |
84471d53ab58
Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
264
diff
changeset
|
4651 gdk_pixbuf_render_pixmap_and_mask(pixbuf, &_PixmapArray[found].pixmap, &_PixmapArray[found].mask, 1); |
84471d53ab58
Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
264
diff
changeset
|
4652 } |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4653 #elif defined(USE_IMLIB) |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4654 image = gdk_imlib_load_image(file); |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4655 |
265
84471d53ab58
Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
264
diff
changeset
|
4656 if(image) |
84471d53ab58
Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
264
diff
changeset
|
4657 { |
84471d53ab58
Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
264
diff
changeset
|
4658 _PixmapArray[found].width = image->rgb_width; |
84471d53ab58
Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
264
diff
changeset
|
4659 _PixmapArray[found].height = image->rgb_height; |
84471d53ab58
Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
264
diff
changeset
|
4660 |
84471d53ab58
Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
264
diff
changeset
|
4661 gdk_imlib_render(image, image->rgb_width, image->rgb_height); |
84471d53ab58
Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
264
diff
changeset
|
4662 _PixmapArray[found].pixmap = gdk_imlib_copy_image(image); |
84471d53ab58
Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
264
diff
changeset
|
4663 _PixmapArray[found].mask = gdk_imlib_copy_mask(image); |
84471d53ab58
Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
264
diff
changeset
|
4664 gdk_imlib_destroy_image(image); |
84471d53ab58
Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
264
diff
changeset
|
4665 } |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4666 #else |
296
d2392cf845e4
Fix crash if dw_icon_load_from_file() called before creating a toplevel
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
285
diff
changeset
|
4667 if (last_window) |
d2392cf845e4
Fix crash if dw_icon_load_from_file() called before creating a toplevel
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
285
diff
changeset
|
4668 _PixmapArray[found].pixmap = gdk_pixmap_create_from_xpm(last_window->window, &_PixmapArray[found].mask, &_colors[DW_CLR_PALEGRAY], file); |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4669 #endif |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4670 DW_MUTEX_UNLOCK; |
265
84471d53ab58
Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
264
diff
changeset
|
4671 if(!_PixmapArray[found].pixmap || !_PixmapArray[found].mask) |
84471d53ab58
Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
264
diff
changeset
|
4672 { |
84471d53ab58
Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
264
diff
changeset
|
4673 _PixmapArray[found].used = 0; |
84471d53ab58
Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
264
diff
changeset
|
4674 _PixmapArray[found].pixmap = _PixmapArray[found].mask = NULL; |
84471d53ab58
Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
264
diff
changeset
|
4675 return 0; |
84471d53ab58
Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
264
diff
changeset
|
4676 } |
84471d53ab58
Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
264
diff
changeset
|
4677 return ret | (1 << 31); |
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:
256
diff
changeset
|
4678 } |
9ea4ac9a097f
Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
256
diff
changeset
|
4679 |
9ea4ac9a097f
Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
256
diff
changeset
|
4680 /* |
3 | 4681 * Frees a loaded resource in OS/2 and Windows. |
4682 * Parameters: | |
4683 * handle: Handle to icon returned by dw_icon_load(). | |
4684 */ | |
4685 void dw_icon_free(unsigned long handle) | |
4686 { | |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4687 /* If it is a private icon, find the item |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4688 * free the associated structures and set |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4689 * the entry to unused. |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4690 */ |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4691 if(handle & (1 << 31)) |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4692 { |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4693 unsigned long id = handle & 0xFFFFFF; |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4694 |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4695 if(id < _PixmapCount && _PixmapArray[id].used) |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4696 { |
316
a07e08f708d6
Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
312
diff
changeset
|
4697 #if GTK_MAJOR_VERSION > 1 |
a07e08f708d6
Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
312
diff
changeset
|
4698 if(_PixmapArray[id].pixbuf) |
a07e08f708d6
Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
312
diff
changeset
|
4699 { |
a07e08f708d6
Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
312
diff
changeset
|
4700 g_object_unref(_PixmapArray[id].pixbuf); |
a07e08f708d6
Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
312
diff
changeset
|
4701 _PixmapArray[id].pixbuf = NULL; |
a07e08f708d6
Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
312
diff
changeset
|
4702 } |
a07e08f708d6
Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
312
diff
changeset
|
4703 #endif |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4704 if(_PixmapArray[id].mask) |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4705 { |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4706 gdk_bitmap_unref(_PixmapArray[id].mask); |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4707 _PixmapArray[id].mask = NULL; |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4708 } |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4709 if(_PixmapArray[id].pixmap) |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4710 { |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4711 gdk_pixmap_unref(_PixmapArray[id].pixmap); |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4712 _PixmapArray[id].pixmap = NULL; |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4713 } |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4714 _PixmapArray[id].used = 0; |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4715 } |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4716 } |
3 | 4717 } |
4718 | |
72
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
4719 /* Clears a CList selection and associated selection list */ |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
4720 void _dw_unselect(GtkWidget *clist) |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
4721 { |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
4722 gtk_clist_unselect_all(GTK_CLIST(clist)); |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
4723 } |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
4724 |
3 | 4725 /* |
4726 * Allocates memory used to populate a container. | |
4727 * Parameters: | |
4728 * handle: Handle to the container window (widget). | |
4729 * rowcount: The number of items to be populated. | |
4730 */ | |
4731 void *dw_container_alloc(HWND handle, int rowcount) | |
4732 { | |
4733 int z, count = 0; | |
4734 GtkWidget *clist; | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
4735 GdkColor *fore, *back; |
3 | 4736 char **blah; |
4737 int _locked_by_me = FALSE; | |
4738 | |
4739 DW_MUTEX_LOCK; | |
4740 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
4741 if(!clist) | |
4742 { | |
4743 DW_MUTEX_UNLOCK; | |
4744 return NULL; | |
4745 } | |
4746 | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4747 count = (int)gtk_object_get_data(GTK_OBJECT(clist), "_dw_colcount"); |
3 | 4748 |
4749 if(!count) | |
4750 { | |
4751 DW_MUTEX_UNLOCK; | |
4752 return NULL; | |
4753 } | |
4754 | |
4755 blah = malloc(sizeof(char *) * count); | |
4756 memset(blah, 0, sizeof(char *) * count); | |
4757 | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4758 fore = (GdkColor *)gtk_object_get_data(GTK_OBJECT(clist), "_dw_foregdk"); |
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4759 back = (GdkColor *)gtk_object_get_data(GTK_OBJECT(clist), "_dw_backgdk"); |
3 | 4760 gtk_clist_freeze(GTK_CLIST(clist)); |
4761 for(z=0;z<rowcount;z++) | |
4762 { | |
4763 gtk_clist_append(GTK_CLIST(clist), blah); | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
4764 if(fore) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
4765 gtk_clist_set_foreground(GTK_CLIST(clist), z, fore); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
4766 if(back) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
4767 gtk_clist_set_background(GTK_CLIST(clist), z, back); |
3 | 4768 } |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4769 gtk_object_set_data(GTK_OBJECT(clist), "_dw_rowcount", (gpointer)rowcount); |
3 | 4770 free(blah); |
4771 DW_MUTEX_UNLOCK; | |
4772 return (void *)handle; | |
4773 } | |
4774 | |
4775 /* | |
4776 * Sets an item in specified row and column to the given data. | |
4777 * Parameters: | |
4778 * handle: Handle to the container window (widget). | |
4779 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
4780 * column: Zero based column of data being set. | |
4781 * row: Zero based row of data being set. | |
4782 * data: Pointer to the data to be added. | |
4783 */ | |
4784 void dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data) | |
4785 { | |
4786 char numbuf[10], textbuffer[100]; | |
4787 int flag = 0; | |
4788 GtkWidget *clist; | |
4789 int _locked_by_me = FALSE; | |
4790 | |
4791 DW_MUTEX_LOCK; | |
4792 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
4793 if(!clist) | |
4794 { | |
4795 DW_MUTEX_UNLOCK; | |
4796 return; | |
4797 } | |
4798 | |
4799 sprintf(numbuf, "%d", column); | |
4800 flag = (int)gtk_object_get_data(GTK_OBJECT(clist), numbuf); | |
4801 | |
4802 if(flag & DW_CFA_BITMAPORICON) | |
4803 { | |
4804 long hicon = *((long *)data); | |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4805 GdkBitmap *bitmap = NULL; |
121
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
4806 GdkPixmap *pixmap = _find_pixmap(&bitmap, hicon, clist, NULL, NULL); |
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
4807 |
3 | 4808 if(pixmap) |
4809 gtk_clist_set_pixmap(GTK_CLIST(clist), row, column, pixmap, bitmap); | |
4810 } | |
4811 else if(flag & DW_CFA_STRING) | |
4812 { | |
4813 char *tmp = *((char **)data); | |
4814 gtk_clist_set_text(GTK_CLIST(clist), row, column, tmp); | |
4815 } | |
4816 else if(flag & DW_CFA_ULONG) | |
4817 { | |
4818 ULONG tmp = *((ULONG *)data); | |
4819 | |
4820 sprintf(textbuffer, "%lu", tmp); | |
4821 | |
4822 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer); | |
4823 } | |
4824 else if(flag & DW_CFA_DATE) | |
4825 { | |
165
d03716228b7f
Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
164
diff
changeset
|
4826 struct tm curtm; |
d03716228b7f
Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
164
diff
changeset
|
4827 CDATE cdate = *((CDATE *)data); |
d03716228b7f
Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
164
diff
changeset
|
4828 |
d03716228b7f
Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
164
diff
changeset
|
4829 curtm.tm_mday = cdate.day; |
d03716228b7f
Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
164
diff
changeset
|
4830 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:
164
diff
changeset
|
4831 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:
164
diff
changeset
|
4832 |
d03716228b7f
Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
164
diff
changeset
|
4833 strftime(textbuffer, 100, "%x", &curtm); |
46
30d091bc7899
Fixed an error in the container date code on Windows and Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
41
diff
changeset
|
4834 |
3 | 4835 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer); |
4836 } | |
4837 else if(flag & DW_CFA_TIME) | |
4838 { | |
165
d03716228b7f
Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
164
diff
changeset
|
4839 struct tm curtm; |
d03716228b7f
Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
164
diff
changeset
|
4840 CTIME ctime = *((CTIME *)data); |
d03716228b7f
Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
164
diff
changeset
|
4841 |
d03716228b7f
Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
164
diff
changeset
|
4842 curtm.tm_hour = ctime.hours; |
d03716228b7f
Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
164
diff
changeset
|
4843 curtm.tm_min = ctime.minutes; |
d03716228b7f
Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
164
diff
changeset
|
4844 curtm.tm_sec = ctime.seconds; |
d03716228b7f
Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
164
diff
changeset
|
4845 |
d03716228b7f
Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
164
diff
changeset
|
4846 strftime(textbuffer, 100, "%X", &curtm); |
d03716228b7f
Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
164
diff
changeset
|
4847 |
3 | 4848 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer); |
4849 } | |
4850 DW_MUTEX_UNLOCK; | |
4851 } | |
4852 | |
4853 /* | |
167
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
4854 * 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
|
4855 * Parameters: |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
4856 * 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
|
4857 * 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
|
4858 * 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
|
4859 * 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
|
4860 */ |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
4861 void dw_container_change_item(HWND handle, int column, int row, void *data) |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
4862 { |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
4863 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
|
4864 } |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
4865 |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
4866 /* |
3 | 4867 * Sets an item in specified row and column to the given data. |
4868 * Parameters: | |
4869 * handle: Handle to the container window (widget). | |
4870 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
4871 * column: Zero based column of data being set. | |
4872 * row: Zero based row of data being set. | |
4873 * data: Pointer to the data to be added. | |
4874 */ | |
4875 void dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, unsigned long icon) | |
4876 { | |
4877 dw_container_set_item(handle, pointer, 0, row, (void *)&icon); | |
4878 dw_container_set_item(handle, pointer, 1, row, (void *)&filename); | |
4879 } | |
4880 | |
4881 /* | |
4882 * Sets an item in specified row and column to the given data. | |
4883 * Parameters: | |
4884 * handle: Handle to the container window (widget). | |
4885 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
4886 * column: Zero based column of data being set. | |
4887 * row: Zero based row of data being set. | |
4888 * data: Pointer to the data to be added. | |
4889 */ | |
4890 void dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data) | |
4891 { | |
4892 dw_container_set_item(handle, pointer, column + 2, row, data); | |
4893 } | |
4894 | |
4895 /* | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4896 * 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:
19
diff
changeset
|
4897 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4898 * 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:
19
diff
changeset
|
4899 * 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:
19
diff
changeset
|
4900 * 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:
19
diff
changeset
|
4901 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4902 void dw_container_set_column_width(HWND handle, int column, int width) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4903 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4904 GtkWidget *clist; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4905 int _locked_by_me = FALSE; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4906 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4907 DW_MUTEX_LOCK; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4908 clist = gtk_object_get_user_data(GTK_OBJECT(handle)); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4909 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4910 if(clist && GTK_IS_CLIST(clist)) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4911 gtk_clist_set_column_width(GTK_CLIST(clist), column, width); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4912 DW_MUTEX_UNLOCK; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4913 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4914 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4915 /* |
3 | 4916 * Sets the title of a row in the container. |
4917 * Parameters: | |
4918 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
4919 * row: Zero based row of data being set. | |
4920 * title: String title of the item. | |
4921 */ | |
4922 void dw_container_set_row_title(void *pointer, int row, char *title) | |
4923 { | |
4924 GtkWidget *clist; | |
4925 int _locked_by_me = FALSE; | |
4926 | |
4927 DW_MUTEX_LOCK; | |
4928 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(pointer)); | |
4929 | |
4930 if(clist) | |
4931 gtk_clist_set_row_data(GTK_CLIST(clist), row, (gpointer)title); | |
4932 DW_MUTEX_UNLOCK; | |
4933 } | |
4934 | |
4935 /* | |
4936 * Sets the title of a row in the container. | |
4937 * Parameters: | |
4938 * handle: Handle to the container window (widget). | |
4939 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
4940 * rowcount: The number of rows to be inserted. | |
4941 */ | |
4942 void dw_container_insert(HWND handle, void *pointer, int rowcount) | |
4943 { | |
4944 GtkWidget *clist; | |
4945 int _locked_by_me = FALSE; | |
4946 | |
4947 DW_MUTEX_LOCK; | |
4948 clist = gtk_object_get_user_data(GTK_OBJECT(handle)); | |
4949 | |
4950 if(clist && GTK_IS_CLIST(clist)) | |
4951 gtk_clist_thaw(GTK_CLIST(clist)); | |
4952 DW_MUTEX_UNLOCK; | |
4953 } | |
4954 | |
4955 /* | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4956 * 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:
19
diff
changeset
|
4957 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4958 * 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:
19
diff
changeset
|
4959 * 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:
19
diff
changeset
|
4960 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4961 void dw_container_delete(HWND handle, int rowcount) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4962 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4963 GtkWidget *clist; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4964 int _locked_by_me = FALSE; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4965 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4966 DW_MUTEX_LOCK; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4967 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle)); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4968 if(clist && GTK_IS_CLIST(clist)) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4969 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4970 int rows, z; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4971 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4972 rows = (int)gtk_object_get_data(GTK_OBJECT(clist), "_dw_rowcount"); |
72
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
4973 |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
4974 _dw_unselect(clist); |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4975 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4976 for(z=0;z<rowcount;z++) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4977 gtk_clist_remove(GTK_CLIST(clist), 0); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4978 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4979 if(rows - rowcount < 0) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4980 rows = 0; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4981 else |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4982 rows -= rowcount; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4983 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4984 gtk_object_set_data(GTK_OBJECT(clist), "_dw_rowcount", (gpointer)rows); |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4985 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4986 DW_MUTEX_UNLOCK; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4987 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4988 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4989 /* |
3 | 4990 * Removes all rows from a container. |
4991 * Parameters: | |
4992 * 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:
51
diff
changeset
|
4993 * redraw: TRUE to cause the container to redraw immediately. |
3 | 4994 */ |
52
0804483f6320
Added a redraw parameter to dw_container_clear().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
51
diff
changeset
|
4995 void dw_container_clear(HWND handle, int redraw) |
3 | 4996 { |
4997 GtkWidget *clist; | |
4998 int _locked_by_me = FALSE; | |
4999 | |
5000 DW_MUTEX_LOCK; | |
5001 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
5002 if(clist && GTK_IS_CLIST(clist)) | |
5003 { | |
72
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
5004 _dw_unselect(clist); |
3 | 5005 gtk_clist_clear(GTK_CLIST(clist)); |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5006 gtk_object_set_data(GTK_OBJECT(clist), "_dw_rowcount", (gpointer)0); |
3 | 5007 } |
5008 DW_MUTEX_UNLOCK; | |
5009 } | |
5010 | |
5011 /* | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5012 * 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:
19
diff
changeset
|
5013 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5014 * 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:
19
diff
changeset
|
5015 * 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:
19
diff
changeset
|
5016 * 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:
19
diff
changeset
|
5017 * 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:
19
diff
changeset
|
5018 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5019 void dw_container_scroll(HWND handle, int direction, long rows) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5020 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5021 GtkAdjustment *adj; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5022 GtkWidget *clist; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5023 int _locked_by_me = FALSE; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5024 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5025 DW_MUTEX_LOCK; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5026 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle)); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5027 if(clist && GTK_IS_CLIST(clist)) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5028 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5029 adj = gtk_clist_get_vadjustment(GTK_CLIST(clist)); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5030 if(adj) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5031 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5032 switch(direction) |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5033 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5034 case DW_SCROLL_TOP: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5035 adj->value = adj->lower; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5036 break; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5037 case DW_SCROLL_BOTTOM: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5038 adj->value = adj->upper; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5039 break; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5040 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5041 gtk_clist_set_vadjustment(GTK_CLIST(clist), adj); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5042 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5043 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5044 DW_MUTEX_UNLOCK; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5045 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5046 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5047 /* |
3 | 5048 * Starts a new query of a container. |
5049 * Parameters: | |
5050 * handle: Handle to the window (widget) to be queried. | |
5051 * flags: If this parameter is DW_CRA_SELECTED it will only | |
5052 * return items that are currently selected. Otherwise | |
5053 * it will return all records in the container. | |
5054 */ | |
5055 char *dw_container_query_start(HWND handle, unsigned long flags) | |
5056 { | |
5057 GtkWidget *clist; | |
5058 GList *list; | |
5059 char *retval = NULL; | |
5060 int _locked_by_me = FALSE; | |
5061 | |
5062 DW_MUTEX_LOCK; | |
5063 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
5064 | |
5065 if(!clist) | |
5066 { | |
5067 DW_MUTEX_UNLOCK; | |
5068 return NULL; | |
5069 } | |
5070 | |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5071 /* These should be separate but right now this will work */ |
364
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
5072 if(flags & DW_CRA_SELECTED) |
3 | 5073 { |
352
feed7567764f
Rewrote the selection code. It is much more simple now and no longer
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
350
diff
changeset
|
5074 list = GTK_CLIST(clist)->selection; |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5075 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5076 if(list) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5077 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5078 gtk_object_set_data(GTK_OBJECT(clist), "_dw_querypos", (gpointer)1); |
352
feed7567764f
Rewrote the selection code. It is much more simple now and no longer
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
350
diff
changeset
|
5079 retval = (char *)gtk_clist_get_row_data(GTK_CLIST(clist), GPOINTER_TO_UINT(list->data)); |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5080 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5081 } |
364
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
5082 else if(flags & DW_CRA_CURSORED) |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
5083 { |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
5084 retval = (char *)gtk_clist_get_row_data(GTK_CLIST(clist), GTK_CLIST(clist)->focus_row); |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
5085 } |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5086 else |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5087 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5088 retval = (char *)gtk_clist_get_row_data(GTK_CLIST(clist), 0); |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5089 gtk_object_set_data(GTK_OBJECT(clist), "_dw_querypos", (gpointer)1); |
3 | 5090 } |
5091 DW_MUTEX_UNLOCK; | |
5092 return retval; | |
5093 } | |
5094 | |
5095 /* | |
5096 * Continues an existing query of a container. | |
5097 * Parameters: | |
5098 * handle: Handle to the window (widget) to be queried. | |
5099 * flags: If this parameter is DW_CRA_SELECTED it will only | |
5100 * return items that are currently selected. Otherwise | |
5101 * it will return all records in the container. | |
5102 */ | |
5103 char *dw_container_query_next(HWND handle, unsigned long flags) | |
5104 { | |
5105 GtkWidget *clist; | |
5106 GList *list; | |
5107 char *retval = NULL; | |
5108 int _locked_by_me = FALSE; | |
5109 | |
5110 DW_MUTEX_LOCK; | |
5111 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
5112 | |
5113 if(!clist) | |
5114 { | |
5115 DW_MUTEX_UNLOCK; | |
5116 return NULL; | |
5117 } | |
5118 | |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5119 /* These should be separate but right now this will work */ |
364
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
5120 if(flags & DW_CRA_SELECTED) |
3 | 5121 { |
352
feed7567764f
Rewrote the selection code. It is much more simple now and no longer
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
350
diff
changeset
|
5122 list = GTK_CLIST(clist)->selection; |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5123 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5124 if(list) |
3 | 5125 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5126 int counter = 0, pos = (int)gtk_object_get_data(GTK_OBJECT(clist), "_dw_querypos"); |
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5127 gtk_object_set_data(GTK_OBJECT(clist), "_dw_querypos", (gpointer)pos+1); |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5128 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5129 while(list && counter < pos) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5130 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5131 list = list->next; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5132 counter++; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5133 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5134 |
352
feed7567764f
Rewrote the selection code. It is much more simple now and no longer
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
350
diff
changeset
|
5135 if(list) |
feed7567764f
Rewrote the selection code. It is much more simple now and no longer
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
350
diff
changeset
|
5136 retval = (char *)gtk_clist_get_row_data(GTK_CLIST(clist), GPOINTER_TO_UINT(list->data)); |
3 | 5137 } |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5138 } |
364
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
5139 else if(flags & DW_CRA_CURSORED) |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
5140 { |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
5141 /* There will only be one item cursored, |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
5142 * retrieve it with dw_container_query_start() |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
5143 */ |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
5144 retval = NULL; |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
5145 } |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5146 else |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5147 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5148 int pos = (int)gtk_object_get_data(GTK_OBJECT(clist), "_dw_querypos"); |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5149 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5150 retval = (char *)gtk_clist_get_row_data(GTK_CLIST(clist), pos); |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5151 gtk_object_set_data(GTK_OBJECT(clist), "_dw_querypos", (gpointer)pos+1); |
3 | 5152 } |
5153 DW_MUTEX_UNLOCK; | |
5154 return retval; | |
5155 } | |
5156 | |
5157 /* | |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5158 * 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:
67
diff
changeset
|
5159 * Parameters: |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5160 * 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:
67
diff
changeset
|
5161 * 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:
67
diff
changeset
|
5162 */ |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5163 void dw_container_cursor(HWND handle, char *text) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5164 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5165 int _locked_by_me = FALSE; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5166 GtkWidget *clist; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5167 int rowcount, z; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5168 char *rowdata; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5169 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5170 DW_MUTEX_LOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5171 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle)); |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5172 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5173 if(!clist) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5174 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5175 DW_MUTEX_UNLOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5176 return; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5177 } |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5178 rowcount = (int)gtk_object_get_data(GTK_OBJECT(clist), "_dw_rowcount"); |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5179 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5180 for(z=0;z<rowcount;z++) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5181 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5182 rowdata = gtk_clist_get_row_data(GTK_CLIST(clist), z); |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5183 if(rowdata == text) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5184 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5185 gfloat pos; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5186 GtkAdjustment *adj = gtk_clist_get_vadjustment(GTK_CLIST(clist)); |
72
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
5187 |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
5188 _dw_unselect(clist); |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
5189 |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5190 gtk_clist_select_row(GTK_CLIST(clist), z, 0); |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5191 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5192 pos = ((adj->upper - adj->lower) * ((gfloat)z/(gfloat)rowcount)) + adj->lower; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5193 gtk_adjustment_set_value(adj, pos); |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5194 DW_MUTEX_UNLOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5195 return; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5196 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5197 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5198 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5199 DW_MUTEX_UNLOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5200 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5201 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5202 /* |
167
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5203 * 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
|
5204 * Parameters: |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5205 * 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
|
5206 * 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
|
5207 */ |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5208 void dw_container_delete_row(HWND handle, char *text) |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5209 { |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5210 int _locked_by_me = FALSE; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5211 GtkWidget *clist; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5212 int rowcount, z; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5213 char *rowdata; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5214 |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5215 DW_MUTEX_LOCK; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5216 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle)); |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5217 |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5218 if(!clist) |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5219 { |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5220 DW_MUTEX_UNLOCK; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5221 return; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5222 } |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5223 rowcount = (int)gtk_object_get_data(GTK_OBJECT(clist), "_dw_rowcount"); |
167
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5224 |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5225 for(z=0;z<rowcount;z++) |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5226 { |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5227 rowdata = gtk_clist_get_row_data(GTK_CLIST(clist), z); |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5228 if(rowdata == text) |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5229 { |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5230 _dw_unselect(clist); |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5231 |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5232 gtk_clist_remove(GTK_CLIST(clist), z); |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5233 |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5234 rowcount--; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5235 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5236 gtk_object_set_data(GTK_OBJECT(clist), "_dw_rowcount", (gpointer)rowcount); |
167
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5237 DW_MUTEX_UNLOCK; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5238 return; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5239 } |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5240 } |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5241 |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5242 DW_MUTEX_UNLOCK; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5243 } |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5244 |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5245 /* |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5246 * 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:
67
diff
changeset
|
5247 * Parameters: |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5248 * 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:
67
diff
changeset
|
5249 */ |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5250 void dw_container_optimize(HWND handle) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5251 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5252 int _locked_by_me = FALSE; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5253 GtkWidget *clist; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5254 int colcount, z; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5255 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5256 DW_MUTEX_LOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5257 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle)); |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5258 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5259 if(!clist) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5260 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5261 DW_MUTEX_UNLOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5262 return; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5263 } |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5264 colcount = (int)gtk_object_get_data(GTK_OBJECT(clist), "_dw_colcount"); |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5265 for(z=0;z<colcount;z++) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5266 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5267 int width = gtk_clist_optimal_column_width(GTK_CLIST(clist), z); |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5268 gtk_clist_set_column_width(GTK_CLIST(clist), z, width); |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5269 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5270 DW_MUTEX_UNLOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5271 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5272 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5273 /* |
3 | 5274 * Creates a rendering context widget (window) to be packed. |
5275 * Parameters: | |
5276 * id: An id to be used with dw_window_from_id. | |
5277 * Returns: | |
5278 * A handle to the widget or NULL on failure. | |
5279 */ | |
5280 HWND dw_render_new(unsigned long id) | |
5281 { | |
5282 int _locked_by_me = FALSE; | |
5283 GtkWidget *tmp; | |
5284 | |
5285 DW_MUTEX_LOCK; | |
5286 tmp = gtk_drawing_area_new(); | |
5287 gtk_widget_set_events(tmp, GDK_EXPOSURE_MASK | |
5288 | GDK_LEAVE_NOTIFY_MASK | |
5289 | GDK_BUTTON_PRESS_MASK | |
267
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
5290 | GDK_KEY_PRESS_MASK |
3 | 5291 | GDK_POINTER_MOTION_MASK |
5292 | GDK_POINTER_MOTION_HINT_MASK); | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5293 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
267
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
5294 GTK_WIDGET_SET_FLAGS(tmp, GTK_CAN_FOCUS); |
3 | 5295 gtk_widget_show(tmp); |
5296 DW_MUTEX_UNLOCK; | |
5297 return tmp; | |
5298 } | |
5299 | |
193
efd4703450fa
Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
185
diff
changeset
|
5300 /* Returns a GdkColor from a DW color */ |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
5301 static GdkColor _internal_color(unsigned long value) |
193
efd4703450fa
Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
185
diff
changeset
|
5302 { |
efd4703450fa
Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
185
diff
changeset
|
5303 if(DW_RGB_COLOR & value) |
efd4703450fa
Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
185
diff
changeset
|
5304 { |
efd4703450fa
Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
185
diff
changeset
|
5305 GdkColor color = { 0, DW_RED_VALUE(value) << 8, DW_GREEN_VALUE(value) << 8, DW_BLUE_VALUE(value) << 8 }; |
efd4703450fa
Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
185
diff
changeset
|
5306 return color; |
efd4703450fa
Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
185
diff
changeset
|
5307 } |
372
3ef2cf70ee07
Code for drawing text with a background color on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
369
diff
changeset
|
5308 if (value < 16) |
193
efd4703450fa
Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
185
diff
changeset
|
5309 return _colors[value]; |
efd4703450fa
Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
185
diff
changeset
|
5310 return _colors[0]; |
efd4703450fa
Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
185
diff
changeset
|
5311 } |
efd4703450fa
Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
185
diff
changeset
|
5312 |
3 | 5313 /* Sets the current foreground drawing color. |
5314 * Parameters: | |
5315 * red: red value. | |
5316 * green: green value. | |
5317 * blue: blue value. | |
5318 */ | |
5319 void dw_color_foreground_set(unsigned long value) | |
5320 { | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5321 int _locked_by_me = FALSE, index = _find_thread_index(dw_thread_id()); |
193
efd4703450fa
Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
185
diff
changeset
|
5322 GdkColor color = _internal_color(value); |
3 | 5323 |
5324 DW_MUTEX_LOCK; | |
373
d04b0699fc28
Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
372
diff
changeset
|
5325 gdk_color_alloc(_dw_cmap, &color); |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5326 _foreground[index] = color; |
3 | 5327 DW_MUTEX_UNLOCK; |
5328 } | |
5329 | |
5330 /* Sets the current background drawing color. | |
5331 * Parameters: | |
5332 * red: red value. | |
5333 * green: green value. | |
5334 * blue: blue value. | |
5335 */ | |
5336 void dw_color_background_set(unsigned long value) | |
5337 { | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5338 int _locked_by_me = FALSE, index = _find_thread_index(dw_thread_id()); |
193
efd4703450fa
Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
185
diff
changeset
|
5339 GdkColor color = _internal_color(value); |
3 | 5340 |
5341 DW_MUTEX_LOCK; | |
373
d04b0699fc28
Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
372
diff
changeset
|
5342 gdk_color_alloc(_dw_cmap, &color); |
d04b0699fc28
Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
372
diff
changeset
|
5343 if(value == DW_CLR_DEFAULT) |
d04b0699fc28
Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
372
diff
changeset
|
5344 _transparent[index] = 1; |
d04b0699fc28
Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
372
diff
changeset
|
5345 else |
d04b0699fc28
Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
372
diff
changeset
|
5346 _transparent[index] = 0; |
d04b0699fc28
Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
372
diff
changeset
|
5347 |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5348 _background[index] = color; |
3 | 5349 DW_MUTEX_UNLOCK; |
5350 } | |
5351 | |
5352 GdkGC *_set_colors(GdkWindow *window) | |
5353 { | |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5354 GdkGC *gc = NULL; |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5355 int index = _find_thread_index(dw_thread_id()); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5356 |
3 | 5357 if(!window) |
5358 return NULL; | |
5359 gc = gdk_gc_new(window); | |
5360 if(gc) | |
5361 { | |
373
d04b0699fc28
Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
372
diff
changeset
|
5362 gdk_gc_set_foreground(gc, &_foreground[index]); |
d04b0699fc28
Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
372
diff
changeset
|
5363 gdk_gc_set_background(gc, &_background[index]); |
3 | 5364 } |
5365 return gc; | |
5366 } | |
5367 | |
5368 /* Draw a point on a window (preferably a render window). | |
5369 * Parameters: | |
5370 * handle: Handle to the window. | |
5371 * pixmap: Handle to the pixmap. (choose only one of these) | |
5372 * x: X coordinate. | |
5373 * y: Y coordinate. | |
5374 */ | |
5375 void dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y) | |
5376 { | |
5377 int _locked_by_me = FALSE; | |
5378 GdkGC *gc = NULL; | |
5379 | |
5380 DW_MUTEX_LOCK; | |
5381 if(handle) | |
5382 gc = _set_colors(handle->window); | |
5383 else if(pixmap) | |
5384 gc = _set_colors(pixmap->pixmap); | |
5385 if(gc) | |
5386 { | |
5387 gdk_draw_point(handle ? handle->window : pixmap->pixmap, gc, x, y); | |
5388 gdk_gc_unref(gc); | |
5389 } | |
5390 DW_MUTEX_UNLOCK; | |
5391 } | |
5392 | |
5393 /* Draw a line on a window (preferably a render window). | |
5394 * Parameters: | |
5395 * handle: Handle to the window. | |
5396 * pixmap: Handle to the pixmap. (choose only one of these) | |
5397 * x1: First X coordinate. | |
5398 * y1: First Y coordinate. | |
5399 * x2: Second X coordinate. | |
5400 * y2: Second Y coordinate. | |
5401 */ | |
5402 void dw_draw_line(HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2) | |
5403 { | |
5404 int _locked_by_me = FALSE; | |
5405 GdkGC *gc = NULL; | |
5406 | |
5407 DW_MUTEX_LOCK; | |
5408 if(handle) | |
5409 gc = _set_colors(handle->window); | |
5410 else if(pixmap) | |
5411 gc = _set_colors(pixmap->pixmap); | |
5412 if(gc) | |
5413 { | |
5414 gdk_draw_line(handle ? handle->window : pixmap->pixmap, gc, x1, y1, x2, y2); | |
5415 gdk_gc_unref(gc); | |
5416 } | |
5417 DW_MUTEX_UNLOCK; | |
5418 } | |
5419 | |
5420 /* Draw a rectangle on a window (preferably a render window). | |
5421 * Parameters: | |
5422 * handle: Handle to the window. | |
5423 * pixmap: Handle to the pixmap. (choose only one of these) | |
5424 * x: X coordinate. | |
5425 * y: Y coordinate. | |
5426 * width: Width of rectangle. | |
5427 * height: Height of rectangle. | |
5428 */ | |
5429 void dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height) | |
5430 { | |
5431 int _locked_by_me = FALSE; | |
5432 GdkGC *gc = NULL; | |
5433 | |
5434 DW_MUTEX_LOCK; | |
5435 if(handle) | |
5436 gc = _set_colors(handle->window); | |
5437 else if(pixmap) | |
5438 gc = _set_colors(pixmap->pixmap); | |
5439 if(gc) | |
5440 { | |
5441 gdk_draw_rectangle(handle ? handle->window : pixmap->pixmap, gc, fill, x, y, width, height); | |
5442 gdk_gc_unref(gc); | |
5443 } | |
5444 DW_MUTEX_UNLOCK; | |
5445 } | |
5446 | |
5447 /* Draw text on a window (preferably a render window). | |
5448 * Parameters: | |
5449 * handle: Handle to the window. | |
5450 * pixmap: Handle to the pixmap. (choose only one of these) | |
5451 * x: X coordinate. | |
5452 * y: Y coordinate. | |
5453 * text: Text to be displayed. | |
5454 */ | |
5455 void dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text) | |
5456 { | |
5457 int _locked_by_me = FALSE; | |
5458 GdkGC *gc = NULL; | |
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:
145
diff
changeset
|
5459 #if GTK_MAJOR_VERSION > 1 |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5460 PangoFontDescription *font; |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5461 #else |
3 | 5462 GdkFont *font; |
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:
145
diff
changeset
|
5463 #endif |
3 | 5464 char *fontname = "fixed"; |
5465 | |
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
|
5466 if(!text) |
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
|
5467 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
|
5468 |
3 | 5469 DW_MUTEX_LOCK; |
5470 if(handle) | |
5471 { | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5472 fontname = (char *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_fontname"); |
3 | 5473 gc = _set_colors(handle->window); |
5474 } | |
5475 else if(pixmap) | |
5476 { | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5477 fontname = (char *)gtk_object_get_data(GTK_OBJECT(pixmap->handle), "_dw_fontname"); |
3 | 5478 gc = _set_colors(pixmap->pixmap); |
5479 } | |
5480 if(gc) | |
5481 { | |
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:
145
diff
changeset
|
5482 #if GTK_MAJOR_VERSION > 1 |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5483 font = pango_font_description_from_string(fontname); |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5484 if(font) |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5485 { |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5486 PangoContext *context = gdk_pango_context_get(); |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5487 |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5488 if(context) |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5489 { |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5490 PangoLayout *layout = pango_layout_new(context); |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5491 |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5492 if(layout) |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5493 { |
372
3ef2cf70ee07
Code for drawing text with a background color on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
369
diff
changeset
|
5494 int index = _find_thread_index(dw_thread_id()); |
3ef2cf70ee07
Code for drawing text with a background color on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
369
diff
changeset
|
5495 |
373
d04b0699fc28
Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
372
diff
changeset
|
5496 gdk_pango_context_set_colormap(context, _dw_cmap); |
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:
145
diff
changeset
|
5497 pango_layout_set_font_description(layout, font); |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5498 pango_layout_set_text(layout, text, strlen(text)); |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5499 |
375
84f79737b7d9
Manually draw the background rectangle with GTK 1.x since it doesn't appear
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
374
diff
changeset
|
5500 if(_transparent[index]) |
372
3ef2cf70ee07
Code for drawing text with a background color on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
369
diff
changeset
|
5501 gdk_draw_layout(handle ? handle->window : pixmap->pixmap, gc, x, y + 2, layout); |
3ef2cf70ee07
Code for drawing text with a background color on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
369
diff
changeset
|
5502 else |
3ef2cf70ee07
Code for drawing text with a background color on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
369
diff
changeset
|
5503 gdk_draw_layout_with_colors(handle ? handle->window : pixmap->pixmap, gc, x, y + 2, layout, &_foreground[index], &_background[index]); |
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:
145
diff
changeset
|
5504 |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5505 g_object_unref(layout); |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5506 } |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5507 g_object_unref(context); |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5508 } |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5509 pango_font_description_free(font); |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5510 } |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5511 #else |
3 | 5512 font = gdk_font_load(fontname); |
148
830f591c87f1
dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
147
diff
changeset
|
5513 if(!font) |
830f591c87f1
dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
147
diff
changeset
|
5514 font = gdk_font_load("fixed"); |
3 | 5515 if(font) |
5516 { | |
379
2e5f3cb38d19
Fix calculations of font heights under GTK 1.2. Unsure full ascent and descent
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
375
diff
changeset
|
5517 gint ascent, descent, width, junk_ascent, junk_descent, junk_width; |
375
84f79737b7d9
Manually draw the background rectangle with GTK 1.x since it doesn't appear
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
374
diff
changeset
|
5518 int index = _find_thread_index(dw_thread_id()); |
84f79737b7d9
Manually draw the background rectangle with GTK 1.x since it doesn't appear
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
374
diff
changeset
|
5519 |
379
2e5f3cb38d19
Fix calculations of font heights under GTK 1.2. Unsure full ascent and descent
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
375
diff
changeset
|
5520 /* gdk_text_extents() calculates ascent and descent based on the string, so |
2e5f3cb38d19
Fix calculations of font heights under GTK 1.2. Unsure full ascent and descent
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
375
diff
changeset
|
5521 * a string without a character with a descent or without an ascent will have |
2e5f3cb38d19
Fix calculations of font heights under GTK 1.2. Unsure full ascent and descent
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
375
diff
changeset
|
5522 * incorrect ascent/descent values |
2e5f3cb38d19
Fix calculations of font heights under GTK 1.2. Unsure full ascent and descent
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
375
diff
changeset
|
5523 */ |
2e5f3cb38d19
Fix calculations of font heights under GTK 1.2. Unsure full ascent and descent
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
375
diff
changeset
|
5524 gdk_text_extents(font, text, strlen(text), NULL, NULL, &width, &junk_ascent, &junk_descent); |
2e5f3cb38d19
Fix calculations of font heights under GTK 1.2. Unsure full ascent and descent
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
375
diff
changeset
|
5525 /* force ascent/descent to be maximum values */ |
383
f040c24bcf26
Slight change to determining font height under GTK 1.2. The solution may
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
379
diff
changeset
|
5526 gdk_text_extents(font, "(g", 2, NULL, NULL, &junk_width, &ascent, &descent); |
375
84f79737b7d9
Manually draw the background rectangle with GTK 1.x since it doesn't appear
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
374
diff
changeset
|
5527 if(!_transparent[index]) |
84f79737b7d9
Manually draw the background rectangle with GTK 1.x since it doesn't appear
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
374
diff
changeset
|
5528 { |
84f79737b7d9
Manually draw the background rectangle with GTK 1.x since it doesn't appear
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
374
diff
changeset
|
5529 GdkGC *gc2 = NULL; |
84f79737b7d9
Manually draw the background rectangle with GTK 1.x since it doesn't appear
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
374
diff
changeset
|
5530 |
84f79737b7d9
Manually draw the background rectangle with GTK 1.x since it doesn't appear
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
374
diff
changeset
|
5531 gc2 = gdk_gc_new(handle ? handle->window : pixmap->pixmap); |
84f79737b7d9
Manually draw the background rectangle with GTK 1.x since it doesn't appear
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
374
diff
changeset
|
5532 if(gc2) |
84f79737b7d9
Manually draw the background rectangle with GTK 1.x since it doesn't appear
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
374
diff
changeset
|
5533 { |
84f79737b7d9
Manually draw the background rectangle with GTK 1.x since it doesn't appear
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
374
diff
changeset
|
5534 gdk_gc_set_foreground(gc2, &_background[index]); |
84f79737b7d9
Manually draw the background rectangle with GTK 1.x since it doesn't appear
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
374
diff
changeset
|
5535 gdk_gc_set_background(gc2, &_background[index]); |
84f79737b7d9
Manually draw the background rectangle with GTK 1.x since it doesn't appear
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
374
diff
changeset
|
5536 } |
383
f040c24bcf26
Slight change to determining font height under GTK 1.2. The solution may
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
379
diff
changeset
|
5537 gdk_draw_rectangle(handle ? handle->window : pixmap->pixmap, gc2, TRUE, x, y, width, ascent + descent + 1); |
375
84f79737b7d9
Manually draw the background rectangle with GTK 1.x since it doesn't appear
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
374
diff
changeset
|
5538 gdk_gc_unref(gc2); |
84f79737b7d9
Manually draw the background rectangle with GTK 1.x since it doesn't appear
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
374
diff
changeset
|
5539 } |
383
f040c24bcf26
Slight change to determining font height under GTK 1.2. The solution may
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
379
diff
changeset
|
5540 gdk_draw_text(handle ? handle->window : pixmap->pixmap, font, gc, x, y + ascent + 1, text, strlen(text)); |
3 | 5541 gdk_font_unref(font); |
5542 } | |
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:
145
diff
changeset
|
5543 #endif |
149
6028f787f7c8
Fixed a graphics context leak in dw_draw_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
148
diff
changeset
|
5544 gdk_gc_unref(gc); |
3 | 5545 } |
5546 DW_MUTEX_UNLOCK; | |
5547 } | |
5548 | |
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
|
5549 /* 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
|
5550 * 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
|
5551 * 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
|
5552 * 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
|
5553 * 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
|
5554 * 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
|
5555 * 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
|
5556 */ |
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
|
5557 void dw_font_text_extents(HWND handle, HPIXMAP pixmap, char *text, int *width, int *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
|
5558 { |
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
|
5559 int _locked_by_me = FALSE; |
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:
145
diff
changeset
|
5560 #if GTK_MAJOR_VERSION > 1 |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5561 PangoFontDescription *font; |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5562 #else |
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
|
5563 GdkFont *font; |
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:
145
diff
changeset
|
5564 #endif |
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
|
5565 char *fontname = NULL; |
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
|
5566 |
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
|
5567 if(!text) |
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
|
5568 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
|
5569 |
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
|
5570 DW_MUTEX_LOCK; |
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
|
5571 if(handle) |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5572 fontname = (char *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_fontname"); |
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
|
5573 else if(pixmap) |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5574 fontname = (char *)gtk_object_get_data(GTK_OBJECT(pixmap->handle), "_dw_fontname"); |
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
|
5575 |
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:
145
diff
changeset
|
5576 #if GTK_MAJOR_VERSION > 1 |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5577 font = pango_font_description_from_string(fontname ? fontname : "monospace 10"); |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5578 if(font) |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5579 { |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5580 PangoContext *context = gdk_pango_context_get(); |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5581 |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5582 if(context) |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5583 { |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5584 PangoLayout *layout = pango_layout_new(context); |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5585 |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5586 if(layout) |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5587 { |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5588 PangoRectangle rect; |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5589 |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5590 pango_layout_set_font_description(layout, font); |
233
f2435b378aed
We should use the logical_rect not the ink_rect when querying the font
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
216
diff
changeset
|
5591 pango_layout_set_text(layout, text, -1); |
f2435b378aed
We should use the logical_rect not the ink_rect when querying the font
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
216
diff
changeset
|
5592 pango_layout_get_pixel_extents(layout, NULL, &rect); |
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:
145
diff
changeset
|
5593 |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5594 if(width) |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5595 *width = rect.width; |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5596 if(height) |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5597 *height = rect.height; |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5598 |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5599 g_object_unref(layout); |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5600 } |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5601 g_object_unref(context); |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5602 } |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5603 pango_font_description_free(font); |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5604 } |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5605 #else |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5606 |
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
|
5607 font = gdk_font_load(fontname ? fontname : "fixed"); |
148
830f591c87f1
dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
147
diff
changeset
|
5608 if(!font) |
830f591c87f1
dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
147
diff
changeset
|
5609 font = gdk_font_load("fixed"); |
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
|
5610 if(font) |
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
|
5611 { |
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
|
5612 if(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
|
5613 *width = gdk_string_width(font, text); |
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
|
5614 if(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
|
5615 *height = gdk_string_height(font, text); |
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
|
5616 gdk_font_unref(font); |
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
|
5617 } |
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:
145
diff
changeset
|
5618 #endif |
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
|
5619 DW_MUTEX_UNLOCK; |
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
|
5620 } |
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
|
5621 |
3 | 5622 /* |
5623 * Creates a pixmap with given parameters. | |
5624 * Parameters: | |
5625 * handle: Window handle the pixmap is associated with. | |
5626 * width: Width of the pixmap in pixels. | |
5627 * height: Height of the pixmap in pixels. | |
5628 * depth: Color depth of the pixmap. | |
5629 * Returns: | |
5630 * A handle to a pixmap or NULL on failure. | |
5631 */ | |
5632 HPIXMAP dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth) | |
5633 { | |
5634 int _locked_by_me = FALSE; | |
5635 HPIXMAP pixmap; | |
5636 | |
5637 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) | |
5638 return NULL; | |
5639 | |
5640 if (!depth) | |
66
664a274a46a6
Fixed color depth problem when creating a new pixmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
63
diff
changeset
|
5641 depth = -1; |
3 | 5642 |
5643 pixmap->width = width; pixmap->height = height; | |
5644 | |
5645 | |
5646 DW_MUTEX_LOCK; | |
5647 pixmap->handle = handle; | |
5648 pixmap->pixmap = gdk_pixmap_new(handle->window, width, height, depth); | |
5649 DW_MUTEX_UNLOCK; | |
5650 return pixmap; | |
5651 } | |
5652 | |
5653 /* | |
241
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5654 * Creates a pixmap from a file. |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5655 * Parameters: |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5656 * handle: Window handle the pixmap is associated with. |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5657 * filename: Name of the file, omit extention to have |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5658 * DW pick the appropriate file extension. |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5659 * (BMP on OS/2 or Windows, XPM on Unix) |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5660 * Returns: |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5661 * A handle to a pixmap or NULL on failure. |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5662 */ |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5663 HPIXMAP dw_pixmap_new_from_file(HWND handle, char *filename) |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5664 { |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5665 int _locked_by_me = FALSE; |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5666 HPIXMAP pixmap; |
244
68158098a092
Implemented dw_pixmap_new_from_file() for GTK 1.x with and without imlib.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
241
diff
changeset
|
5667 #ifndef USE_IMLIB |
241
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5668 GdkBitmap *bitmap = NULL; |
244
68158098a092
Implemented dw_pixmap_new_from_file() for GTK 1.x with and without imlib.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
241
diff
changeset
|
5669 #endif |
241
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5670 #if GTK_MAJOR_VERSION > 1 |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5671 GdkPixbuf *pixbuf; |
244
68158098a092
Implemented dw_pixmap_new_from_file() for GTK 1.x with and without imlib.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
241
diff
changeset
|
5672 #elif defined(USE_IMLIB) |
68158098a092
Implemented dw_pixmap_new_from_file() for GTK 1.x with and without imlib.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
241
diff
changeset
|
5673 GdkImlibImage *image; |
241
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5674 #endif |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5675 char *file = alloca(strlen(filename) + 5); |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5676 |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5677 if (!file || !(pixmap = calloc(1,sizeof(struct _hpixmap)))) |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5678 return NULL; |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5679 |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5680 strcpy(file, filename); |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5681 |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5682 /* 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:
239
diff
changeset
|
5683 if(access(file, 04) != 0) |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5684 { |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5685 /* Try with .xpm extention */ |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5686 strcat(file, ".xpm"); |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5687 if(access(file, 04) != 0) |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5688 { |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5689 free(pixmap); |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5690 return NULL; |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5691 } |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5692 } |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5693 |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5694 DW_MUTEX_LOCK; |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5695 #if GTK_MAJOR_VERSION > 1 |
246
bdaaa06285fd
Missing parameter to gdk_pixmap_new_from_file() for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
245
diff
changeset
|
5696 pixbuf = gdk_pixbuf_new_from_file(file, NULL); |
241
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5697 |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5698 pixmap->width = gdk_pixbuf_get_width(pixbuf); |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5699 pixmap->height = gdk_pixbuf_get_height(pixbuf); |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5700 |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5701 gdk_pixbuf_render_pixmap_and_mask(pixbuf, &pixmap->pixmap, &bitmap, 1); |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5702 g_object_unref(pixbuf); |
244
68158098a092
Implemented dw_pixmap_new_from_file() for GTK 1.x with and without imlib.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
241
diff
changeset
|
5703 #elif defined(USE_IMLIB) |
68158098a092
Implemented dw_pixmap_new_from_file() for GTK 1.x with and without imlib.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
241
diff
changeset
|
5704 image = gdk_imlib_load_image(file); |
68158098a092
Implemented dw_pixmap_new_from_file() for GTK 1.x with and without imlib.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
241
diff
changeset
|
5705 |
68158098a092
Implemented dw_pixmap_new_from_file() for GTK 1.x with and without imlib.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
241
diff
changeset
|
5706 pixmap->width = image->rgb_width; |
68158098a092
Implemented dw_pixmap_new_from_file() for GTK 1.x with and without imlib.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
241
diff
changeset
|
5707 pixmap->height = image->rgb_height; |
68158098a092
Implemented dw_pixmap_new_from_file() for GTK 1.x with and without imlib.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
241
diff
changeset
|
5708 |
245
11baf43efbc2
Must call gdk_imlib_render() before gdk_imlib_copy_image().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
244
diff
changeset
|
5709 gdk_imlib_render(image, pixmap->width, pixmap->height); |
11baf43efbc2
Must call gdk_imlib_render() before gdk_imlib_copy_image().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
244
diff
changeset
|
5710 pixmap->pixmap = gdk_imlib_copy_image(image); |
244
68158098a092
Implemented dw_pixmap_new_from_file() for GTK 1.x with and without imlib.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
241
diff
changeset
|
5711 gdk_imlib_destroy_image(image); |
68158098a092
Implemented dw_pixmap_new_from_file() for GTK 1.x with and without imlib.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
241
diff
changeset
|
5712 #else |
68158098a092
Implemented dw_pixmap_new_from_file() for GTK 1.x with and without imlib.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
241
diff
changeset
|
5713 pixmap->pixmap = gdk_pixmap_create_from_xpm(handle->window, &bitmap, &_colors[DW_CLR_PALEGRAY], file); |
241
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5714 #endif |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5715 pixmap->handle = handle; |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5716 DW_MUTEX_UNLOCK; |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5717 return pixmap; |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5718 } |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5719 |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5720 /* |
3 | 5721 * Creates a pixmap from internal resource graphic specified by id. |
5722 * Parameters: | |
5723 * handle: Window handle the pixmap is associated with. | |
5724 * id: Resource ID associated with requested pixmap. | |
5725 * Returns: | |
5726 * A handle to a pixmap or NULL on failure. | |
5727 */ | |
5728 HPIXMAP dw_pixmap_grab(HWND handle, ULONG id) | |
5729 { | |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5730 GdkBitmap *bitmap = NULL; |
3 | 5731 HPIXMAP pixmap; |
5732 int _locked_by_me = FALSE; | |
5733 | |
5734 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) | |
5735 return NULL; | |
5736 | |
5737 | |
5738 DW_MUTEX_LOCK; | |
121
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
5739 pixmap->pixmap = _find_pixmap(&bitmap, id, handle, &pixmap->width, &pixmap->height); |
3 | 5740 if(pixmap->pixmap) |
5741 { | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5742 #if GTK_MAJOR_VERSION < 2 |
3 | 5743 GdkPixmapPrivate *pvt = (GdkPixmapPrivate *)pixmap->pixmap; |
5744 pixmap->width = pvt->width; pixmap->height = pvt->height; | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
5745 #endif |
3 | 5746 } |
5747 DW_MUTEX_UNLOCK; | |
5748 return pixmap; | |
5749 } | |
5750 | |
5751 /* Call this after drawing to the screen to make sure | |
5752 * anything you have drawn is visible. | |
5753 */ | |
5754 void dw_flush(void) | |
5755 { | |
133
85f8ba78736d
Don't call gdk_flush() in GTK 2.0. It doesn't seem to be necessary and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
132
diff
changeset
|
5756 #if GTK_MAJOR_VERSION < 2 |
3 | 5757 int _locked_by_me = FALSE; |
5758 | |
5759 DW_MUTEX_LOCK; | |
5760 gdk_flush(); | |
5761 DW_MUTEX_UNLOCK; | |
133
85f8ba78736d
Don't call gdk_flush() in GTK 2.0. It doesn't seem to be necessary and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
132
diff
changeset
|
5762 #endif |
3 | 5763 } |
5764 | |
5765 /* | |
5766 * Destroys an allocated pixmap. | |
5767 * Parameters: | |
5768 * pixmap: Handle to a pixmap returned by | |
5769 * dw_pixmap_new.. | |
5770 */ | |
5771 void dw_pixmap_destroy(HPIXMAP pixmap) | |
5772 { | |
5773 int _locked_by_me = FALSE; | |
5774 | |
5775 DW_MUTEX_LOCK; | |
5776 gdk_pixmap_unref(pixmap->pixmap); | |
5777 free(pixmap); | |
5778 DW_MUTEX_UNLOCK; | |
5779 } | |
5780 | |
5781 /* | |
5782 * Copies from one item to another. | |
5783 * Parameters: | |
5784 * dest: Destination window handle. | |
5785 * destp: Destination pixmap. (choose only one). | |
5786 * xdest: X coordinate of destination. | |
5787 * ydest: Y coordinate of destination. | |
5788 * width: Width of area to copy. | |
5789 * height: Height of area to copy. | |
5790 * src: Source window handle. | |
5791 * srcp: Source pixmap. (choose only one). | |
5792 * xsrc: X coordinate of source. | |
5793 * ysrc: Y coordinate of source. | |
5794 */ | |
5795 void dw_pixmap_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc) | |
5796 { | |
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
|
5797 /* Ok, these #ifdefs are going to get a bit confusing because |
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
|
5798 * when using gdk-pixbuf, pixmaps are really pixbufs, so we |
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
|
5799 * have to use the pixbuf functions on them, and thus convoluting |
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
|
5800 * the code here a bit. -Brian |
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
|
5801 */ |
3 | 5802 int _locked_by_me = FALSE; |
5803 GdkGC *gc = NULL; | |
5804 | |
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
|
5805 if((!dest && (!destp || !destp->pixmap)) || (!src && (!srcp || !srcp->pixmap))) |
3 | 5806 return; |
5807 | |
5808 DW_MUTEX_LOCK; | |
5809 if(dest) | |
5810 gc = _set_colors(dest->window); | |
5811 else if(src) | |
5812 gc = _set_colors(src->window); | |
5813 else if(destp) | |
5814 gc = gdk_gc_new(destp->pixmap); | |
5815 else if(srcp) | |
5816 gc = gdk_gc_new(srcp->pixmap); | |
122
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
5817 |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
5818 if(gc) |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
5819 { |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
5820 gdk_draw_pixmap(dest ? dest->window : destp->pixmap, gc, src ? src->window : srcp->pixmap, xsrc, ysrc, xdest, ydest, width, height); |
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
|
5821 gdk_gc_unref(gc); |
3 | 5822 } |
5823 DW_MUTEX_UNLOCK; | |
5824 } | |
5825 | |
5826 /* | |
5827 * Emits a beep. | |
5828 * Parameters: | |
5829 * freq: Frequency. | |
5830 * dur: Duration. | |
5831 */ | |
5832 void dw_beep(int freq, int dur) | |
5833 { | |
5834 int _locked_by_me = FALSE; | |
5835 | |
5836 DW_MUTEX_LOCK; | |
5837 gdk_beep(); | |
5838 DW_MUTEX_UNLOCK; | |
5839 } | |
5840 | |
157
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5841 void _my_strlwr(char *buf) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5842 { |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5843 int z, len = strlen(buf); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5844 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5845 for(z=0;z<len;z++) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5846 { |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5847 if(buf[z] >= 'A' && buf[z] <= 'Z') |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5848 buf[z] -= 'A' - 'a'; |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5849 } |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5850 } |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5851 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5852 /* Open a shared library and return a handle. |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5853 * Parameters: |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5854 * name: Base name of the shared library. |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5855 * handle: Pointer to a module handle, |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5856 * will be filled in with the handle. |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5857 */ |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5858 int dw_module_load(char *name, HMOD *handle) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5859 { |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5860 int len; |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5861 char *newname; |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5862 char errorbuf[1024]; |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5863 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5864 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5865 if(!handle) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5866 return -1; |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5867 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5868 if((len = strlen(name)) == 0) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5869 return -1; |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5870 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5871 /* Lenth + "lib" + ".so" + NULL */ |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5872 newname = malloc(len + 7); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5873 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5874 if(!newname) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5875 return -1; |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5876 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5877 sprintf(newname, "lib%s.so", name); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5878 _my_strlwr(newname); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5879 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5880 *handle = dlopen(newname, RTLD_NOW); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5881 if(*handle == NULL) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5882 { |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5883 strncpy(errorbuf, dlerror(), 1024); |
164
d35771f70bdd
Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
163
diff
changeset
|
5884 printf("%s\n", errorbuf); |
157
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5885 sprintf(newname, "lib%s.so", name); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5886 *handle = dlopen(newname, RTLD_NOW); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5887 } |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5888 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5889 free(newname); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5890 |
163
0322836c5299
Return -1 on error from dw_module_load().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
162
diff
changeset
|
5891 return (NULL == *handle) ? -1 : 0; |
157
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5892 } |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5893 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5894 /* Queries the address of a symbol within open handle. |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5895 * Parameters: |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5896 * handle: Module handle returned by dw_module_load() |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5897 * name: Name of the symbol you want the address of. |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5898 * func: A pointer to a function pointer, to obtain |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5899 * the address. |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5900 */ |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5901 int dw_module_symbol(HMOD handle, char *name, void**func) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5902 { |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5903 if(!func || !name) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5904 return -1; |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5905 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5906 if(strlen(name) == 0) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5907 return -1; |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5908 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5909 *func = (void*)dlsym(handle, name); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5910 return (NULL == *func); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5911 } |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5912 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5913 /* Frees the shared library previously opened. |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5914 * Parameters: |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5915 * handle: Module handle returned by dw_module_load() |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5916 */ |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5917 int dw_module_close(HMOD handle) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5918 { |
162
df59a3fc6de6
Fixed a minor bug in dw_module_close().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
157
diff
changeset
|
5919 if(handle) |
df59a3fc6de6
Fixed a minor bug in dw_module_close().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
157
diff
changeset
|
5920 return dlclose(handle); |
df59a3fc6de6
Fixed a minor bug in dw_module_close().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
157
diff
changeset
|
5921 return 0; |
157
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5922 } |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5923 |
3 | 5924 /* |
5925 * Returns the handle to an unnamed mutex semaphore. | |
5926 */ | |
5927 HMTX dw_mutex_new(void) | |
5928 { | |
239
403b07f873e1
Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
237
diff
changeset
|
5929 HMTX mutex = malloc(sizeof(pthread_mutex_t)); |
403b07f873e1
Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
237
diff
changeset
|
5930 |
403b07f873e1
Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
237
diff
changeset
|
5931 pthread_mutex_init(mutex, NULL); |
3 | 5932 return mutex; |
5933 } | |
5934 | |
5935 /* | |
5936 * Closes a semaphore created by dw_mutex_new(). | |
5937 * Parameters: | |
5938 * mutex: The handle to the mutex returned by dw_mutex_new(). | |
5939 */ | |
5940 void dw_mutex_close(HMTX mutex) | |
5941 { | |
239
403b07f873e1
Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
237
diff
changeset
|
5942 if(mutex) |
403b07f873e1
Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
237
diff
changeset
|
5943 { |
403b07f873e1
Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
237
diff
changeset
|
5944 pthread_mutex_destroy(mutex); |
403b07f873e1
Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
237
diff
changeset
|
5945 free(mutex); |
403b07f873e1
Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
237
diff
changeset
|
5946 } |
3 | 5947 } |
5948 | |
5949 /* | |
5950 * Tries to gain access to the semaphore, if it can't it blocks. | |
5951 * Parameters: | |
5952 * mutex: The handle to the mutex returned by dw_mutex_new(). | |
5953 */ | |
5954 void dw_mutex_lock(HMTX mutex) | |
5955 { | |
96
baaf4b04d284
Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
94
diff
changeset
|
5956 /* If we are being called from an event handler we must release |
baaf4b04d284
Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
94
diff
changeset
|
5957 * the GTK mutex so we don't deadlock. |
baaf4b04d284
Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
94
diff
changeset
|
5958 */ |
baaf4b04d284
Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
94
diff
changeset
|
5959 if(pthread_self() == _dw_thread) |
baaf4b04d284
Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
94
diff
changeset
|
5960 gdk_threads_leave(); |
baaf4b04d284
Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
94
diff
changeset
|
5961 |
239
403b07f873e1
Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
237
diff
changeset
|
5962 pthread_mutex_lock(mutex); |
96
baaf4b04d284
Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
94
diff
changeset
|
5963 |
baaf4b04d284
Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
94
diff
changeset
|
5964 /* And of course relock it when we have acquired the mutext */ |
baaf4b04d284
Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
94
diff
changeset
|
5965 if(pthread_self() == _dw_thread) |
baaf4b04d284
Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
94
diff
changeset
|
5966 gdk_threads_enter(); |
3 | 5967 } |
5968 | |
5969 /* | |
5970 * Reliquishes the access to the semaphore. | |
5971 * Parameters: | |
5972 * mutex: The handle to the mutex returned by dw_mutex_new(). | |
5973 */ | |
5974 void dw_mutex_unlock(HMTX mutex) | |
5975 { | |
239
403b07f873e1
Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
237
diff
changeset
|
5976 pthread_mutex_unlock(mutex); |
3 | 5977 } |
5978 | |
5979 /* | |
5980 * Returns the handle to an unnamed event semaphore. | |
5981 */ | |
5982 HEV dw_event_new(void) | |
5983 { | |
5984 HEV eve = (HEV)malloc(sizeof(struct _dw_unix_event)); | |
5985 | |
5986 if(!eve) | |
5987 return NULL; | |
5988 | |
5989 /* We need to be careful here, mutexes on Linux are | |
5990 * FAST by default but are error checking on other | |
5991 * systems such as FreeBSD and OS/2, perhaps others. | |
5992 */ | |
5993 pthread_mutex_init (&(eve->mutex), NULL); | |
5994 pthread_mutex_lock (&(eve->mutex)); | |
5995 pthread_cond_init (&(eve->event), NULL); | |
5996 | |
5997 pthread_mutex_unlock (&(eve->mutex)); | |
5998 eve->alive = 1; | |
5999 eve->posted = 0; | |
6000 | |
6001 return eve; | |
6002 } | |
6003 | |
6004 /* | |
6005 * Resets a semaphore created by dw_event_new(). | |
6006 * Parameters: | |
6007 * eve: The handle to the event returned by dw_event_new(). | |
6008 */ | |
6009 int dw_event_reset (HEV eve) | |
6010 { | |
6011 if(!eve) | |
6012 return FALSE; | |
6013 | |
6014 pthread_mutex_lock (&(eve->mutex)); | |
6015 pthread_cond_broadcast (&(eve->event)); | |
6016 pthread_cond_init (&(eve->event), NULL); | |
6017 eve->posted = 0; | |
6018 pthread_mutex_unlock (&(eve->mutex)); | |
6019 return 0; | |
6020 } | |
6021 | |
6022 /* | |
6023 * Posts a semaphore created by dw_event_new(). Causing all threads | |
6024 * waiting on this event in dw_event_wait to continue. | |
6025 * Parameters: | |
6026 * eve: The handle to the event returned by dw_event_new(). | |
6027 */ | |
6028 int dw_event_post (HEV eve) | |
6029 { | |
6030 if(!eve) | |
6031 return FALSE; | |
6032 | |
6033 pthread_mutex_lock (&(eve->mutex)); | |
6034 pthread_cond_broadcast (&(eve->event)); | |
6035 eve->posted = 1; | |
6036 pthread_mutex_unlock (&(eve->mutex)); | |
6037 return 0; | |
6038 } | |
6039 | |
6040 /* | |
6041 * Waits on a semaphore created by dw_event_new(), until the | |
6042 * event gets posted or until the timeout expires. | |
6043 * Parameters: | |
6044 * eve: The handle to the event returned by dw_event_new(). | |
6045 */ | |
6046 int dw_event_wait(HEV eve, unsigned long timeout) | |
6047 { | |
6048 int rc; | |
6049 struct timeval now; | |
6050 struct timespec timeo; | |
6051 | |
6052 if(!eve) | |
6053 return FALSE; | |
6054 | |
6055 if(eve->posted) | |
6056 return 0; | |
6057 | |
6058 pthread_mutex_lock (&(eve->mutex)); | |
6059 gettimeofday(&now, 0); | |
6060 timeo.tv_sec = now.tv_sec + (timeout / 1000); | |
6061 timeo.tv_nsec = now.tv_usec * 1000; | |
6062 rc = pthread_cond_timedwait (&(eve->event), &(eve->mutex), &timeo); | |
6063 pthread_mutex_unlock (&(eve->mutex)); | |
6064 if(!rc) | |
6065 return 1; | |
6066 if(rc == ETIMEDOUT) | |
6067 return -1; | |
6068 return 0; | |
6069 } | |
6070 | |
6071 /* | |
6072 * Closes a semaphore created by dw_event_new(). | |
6073 * Parameters: | |
6074 * eve: The handle to the event returned by dw_event_new(). | |
6075 */ | |
6076 int dw_event_close(HEV *eve) | |
6077 { | |
6078 if(!eve || !(*eve)) | |
6079 return FALSE; | |
6080 | |
6081 pthread_mutex_lock (&((*eve)->mutex)); | |
6082 pthread_cond_destroy (&((*eve)->event)); | |
6083 pthread_mutex_unlock (&((*eve)->mutex)); | |
6084 pthread_mutex_destroy (&((*eve)->mutex)); | |
6085 free(*eve); | |
6086 *eve = NULL; | |
6087 | |
6088 return TRUE; | |
6089 } | |
6090 | |
6091 /* | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6092 * Setup thread independent color sets. |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6093 */ |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6094 void _dwthreadstart(void *data) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6095 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6096 void (*threadfunc)(void *) = NULL; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6097 void **tmp = (void **)data; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6098 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6099 threadfunc = (void (*)(void *))tmp[0]; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6100 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6101 _dw_thread_add(dw_thread_id()); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6102 threadfunc(tmp[1]); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6103 _dw_thread_remove(dw_thread_id()); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6104 free(tmp); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6105 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6106 /* |
3 | 6107 * Creates a new thread with a starting point of func. |
6108 * Parameters: | |
6109 * func: Function which will be run in the new thread. | |
6110 * data: Parameter(s) passed to the function. | |
6111 * stack: Stack size of new thread (OS/2 and Windows only). | |
6112 */ | |
6113 DWTID dw_thread_new(void *func, void *data, int stack) | |
6114 { | |
6115 DWTID gtkthread; | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6116 void **tmp = malloc(sizeof(void *) * 2); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6117 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6118 tmp[0] = func; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6119 tmp[1] = data; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6120 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6121 pthread_create(>kthread, NULL, (void *)_dwthreadstart, (void *)tmp); |
3 | 6122 return gtkthread; |
6123 } | |
6124 | |
6125 /* | |
6126 * Ends execution of current thread immediately. | |
6127 */ | |
6128 void dw_thread_end(void) | |
6129 { | |
6130 pthread_exit(NULL); | |
6131 } | |
6132 | |
6133 /* | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6134 * Returns the current thread's ID. |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6135 */ |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6136 DWTID dw_thread_id(void) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6137 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6138 return (DWTID)pthread_self(); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6139 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6140 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6141 /* |
3 | 6142 * Cleanly terminates a DW session, should be signal handler safe. |
6143 * Parameters: | |
6144 * exitcode: Exit code reported to the operating system. | |
6145 */ | |
6146 void dw_exit(int exitcode) | |
6147 { | |
6148 exit(exitcode); | |
6149 } | |
6150 | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6151 #define DW_EXPAND (GTK_EXPAND | GTK_SHRINK | GTK_FILL) |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6152 |
3 | 6153 /* |
6154 * Pack windows (widgets) into a box from the end (or bottom). | |
6155 * Parameters: | |
6156 * box: Window handle of the box to be packed into. | |
6157 * item: Window handle of the item to be back. | |
6158 * width: Width in pixels of the item or -1 to be self determined. | |
6159 * height: Height in pixels of the item or -1 to be self determined. | |
6160 * hsize: TRUE if the window (widget) should expand horizontally to fill space given. | |
6161 * vsize: TRUE if the window (widget) should expand vertically to fill space given. | |
6162 * pad: Number of pixels of padding around the item. | |
6163 */ | |
6164 void dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) | |
6165 { | |
6166 int _locked_by_me = FALSE; | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6167 GtkWidget *tmp; |
3 | 6168 |
6169 if(!box) | |
6170 return; | |
6171 | |
6172 DW_MUTEX_LOCK; | |
6173 | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6174 if((tmp = gtk_object_get_data(GTK_OBJECT(box), "_dw_boxhandle"))) |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6175 box = tmp; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6176 |
3 | 6177 if(!item) |
6178 { | |
6179 item = gtk_label_new(""); | |
6180 gtk_widget_show(item); | |
6181 } | |
6182 | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6183 if(GTK_IS_TABLE(box)) |
3 | 6184 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6185 int boxcount = (int)gtk_object_get_data(GTK_OBJECT(box), "_dw_boxcount"); |
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6186 int boxtype = (int)gtk_object_get_data(GTK_OBJECT(box), "_dw_boxtype"); |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6187 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6188 /* If the item being packed is a box, then we use it's padding |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6189 * instead of the padding specified on the pack line, this is |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6190 * due to a bug in the OS/2 and Win32 renderer and a limitation |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6191 * of the GtkTable class. |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6192 */ |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6193 if(GTK_IS_TABLE(item)) |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6194 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6195 GtkWidget *eventbox = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(item), "_dw_eventbox"); |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6196 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6197 if(eventbox) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6198 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6199 gtk_container_add(GTK_CONTAINER(eventbox), item); |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6200 pad = (int)gtk_object_get_data(GTK_OBJECT(item), "_dw_boxpad"); |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6201 item = eventbox; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6202 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6203 } |
438
fac2afe7bda3
Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
429
diff
changeset
|
6204 else |
fac2afe7bda3
Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
429
diff
changeset
|
6205 { |
fac2afe7bda3
Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
429
diff
changeset
|
6206 /* Only show warning if item is not a box */ |
fac2afe7bda3
Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
429
diff
changeset
|
6207 if ( width == 0 && hsize == FALSE ) |
fac2afe7bda3
Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
429
diff
changeset
|
6208 dw_messagebox("dw_box_pack_end()", DW_MB_OK|DW_MB_ERROR, "Width and expand Horizonal both unset for box: %x item: %x",box,item); |
fac2afe7bda3
Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
429
diff
changeset
|
6209 if ( height == 0 && vsize == FALSE ) |
fac2afe7bda3
Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
429
diff
changeset
|
6210 dw_messagebox("dw_box_pack_end()", DW_MB_OK|DW_MB_ERROR, "Height and expand Vertical both unset for box: %x item: %x",box,item); |
fac2afe7bda3
Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
429
diff
changeset
|
6211 } |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6212 |
283
54aafc134652
BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
282
diff
changeset
|
6213 if(boxtype == DW_VERT) |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6214 gtk_table_resize(GTK_TABLE(box), boxcount + 1, 1); |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6215 else |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6216 gtk_table_resize(GTK_TABLE(box), 1, boxcount + 1); |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6217 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6218 gtk_table_attach(GTK_TABLE(box), item, 0, 1, 0, 1, hsize ? DW_EXPAND : 0, vsize ? DW_EXPAND : 0, pad, pad); |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6219 gtk_object_set_data(GTK_OBJECT(box), "_dw_boxcount", (gpointer)boxcount + 1); |
3 | 6220 gtk_widget_set_usize(item, width, height); |
6221 if(GTK_IS_RADIO_BUTTON(item)) | |
6222 { | |
6223 GSList *group; | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6224 GtkWidget *groupstart = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(box), "_dw_group"); |
3 | 6225 |
6226 if(groupstart) | |
6227 { | |
6228 group = gtk_radio_button_group(GTK_RADIO_BUTTON(groupstart)); | |
6229 gtk_radio_button_set_group(GTK_RADIO_BUTTON(item), group); | |
6230 } | |
6231 else | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6232 gtk_object_set_data(GTK_OBJECT(box), "_dw_group", (gpointer)item); |
3 | 6233 } |
6234 } | |
6235 else | |
6236 { | |
6237 GtkWidget *vbox = gtk_vbox_new(FALSE, 0); | |
6238 | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6239 if(GTK_IS_TABLE(item)) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6240 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6241 GtkWidget *eventbox = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(item), "_dw_eventbox"); |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6242 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6243 if(eventbox) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6244 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6245 gtk_container_add(GTK_CONTAINER(eventbox), item); |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6246 pad = (int)gtk_object_get_data(GTK_OBJECT(item), "_dw_boxpad"); |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6247 item = eventbox; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6248 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6249 } |
438
fac2afe7bda3
Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
429
diff
changeset
|
6250 else |
fac2afe7bda3
Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
429
diff
changeset
|
6251 { |
fac2afe7bda3
Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
429
diff
changeset
|
6252 /* Only show warning if item is not a box */ |
fac2afe7bda3
Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
429
diff
changeset
|
6253 if ( width == 0 && hsize == FALSE ) |
fac2afe7bda3
Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
429
diff
changeset
|
6254 dw_messagebox("dw_box_pack_end()", DW_MB_OK|DW_MB_ERROR, "Width and expand Horizonal both unset for box: %x item: %x",box,item); |
fac2afe7bda3
Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
429
diff
changeset
|
6255 if ( height == 0 && vsize == FALSE ) |
fac2afe7bda3
Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
429
diff
changeset
|
6256 dw_messagebox("dw_box_pack_end()", DW_MB_OK|DW_MB_ERROR, "Height and expand Vertical both unset for box: %x item: %x",box,item); |
fac2afe7bda3
Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
429
diff
changeset
|
6257 } |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6258 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6259 gtk_container_border_width(GTK_CONTAINER(box), pad); |
3 | 6260 gtk_container_add(GTK_CONTAINER(box), vbox); |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6261 gtk_box_pack_end(GTK_BOX(vbox), item, TRUE, TRUE, 0); |
3 | 6262 gtk_widget_show(vbox); |
6263 | |
6264 gtk_widget_set_usize(item, width, height); | |
6265 gtk_object_set_user_data(GTK_OBJECT(box), vbox); | |
6266 } | |
6267 DW_MUTEX_UNLOCK; | |
6268 } | |
6269 | |
6270 /* | |
6271 * Sets the size of a given window (widget). | |
6272 * Parameters: | |
6273 * handle: Window (widget) handle. | |
6274 * width: New width in pixels. | |
6275 * height: New height in pixels. | |
6276 */ | |
6277 void dw_window_set_usize(HWND handle, unsigned long width, unsigned long height) | |
6278 { | |
6279 int _locked_by_me = FALSE; | |
6280 | |
148
830f591c87f1
dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
147
diff
changeset
|
6281 if(!handle) |
830f591c87f1
dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
147
diff
changeset
|
6282 return; |
830f591c87f1
dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
147
diff
changeset
|
6283 |
3 | 6284 DW_MUTEX_LOCK; |
6285 if(GTK_IS_WINDOW(handle)) | |
148
830f591c87f1
dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
147
diff
changeset
|
6286 { |
3 | 6287 _size_allocate(GTK_WINDOW(handle)); |
148
830f591c87f1
dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
147
diff
changeset
|
6288 if(handle->window) |
830f591c87f1
dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
147
diff
changeset
|
6289 gdk_window_resize(handle->window, width - _dw_border_width, height - _dw_border_height); |
830f591c87f1
dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
147
diff
changeset
|
6290 gtk_window_set_default_size(GTK_WINDOW(handle), width - _dw_border_width, height - _dw_border_height); |
272
49ac97060328
Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
271
diff
changeset
|
6291 if(!gtk_object_get_data(GTK_OBJECT(handle), "_dw_size")) |
49ac97060328
Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
271
diff
changeset
|
6292 { |
49ac97060328
Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
271
diff
changeset
|
6293 gtk_object_set_data(GTK_OBJECT(handle), "_dw_width", (gpointer)width - _dw_border_width); |
49ac97060328
Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
271
diff
changeset
|
6294 gtk_object_set_data(GTK_OBJECT(handle), "_dw_height", (gpointer)height - _dw_border_height); |
49ac97060328
Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
271
diff
changeset
|
6295 } |
148
830f591c87f1
dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
147
diff
changeset
|
6296 } |
3 | 6297 else |
6298 gtk_widget_set_usize(handle, width, height); | |
6299 DW_MUTEX_UNLOCK; | |
6300 } | |
6301 | |
6302 /* | |
6303 * Returns the width of the screen. | |
6304 */ | |
6305 int dw_screen_width(void) | |
6306 { | |
6307 int retval; | |
6308 int _locked_by_me = FALSE; | |
6309 | |
6310 DW_MUTEX_LOCK; | |
6311 retval = gdk_screen_width(); | |
6312 DW_MUTEX_UNLOCK; | |
6313 return retval; | |
6314 } | |
6315 | |
6316 /* | |
6317 * Returns the height of the screen. | |
6318 */ | |
6319 int dw_screen_height(void) | |
6320 { | |
6321 int retval; | |
6322 int _locked_by_me = FALSE; | |
6323 | |
6324 DW_MUTEX_UNLOCK; | |
6325 retval = gdk_screen_height(); | |
6326 DW_MUTEX_UNLOCK; | |
6327 return retval; | |
6328 } | |
6329 | |
6330 /* This should return the current color depth */ | |
6331 unsigned long dw_color_depth(void) | |
6332 { | |
6333 int retval; | |
6334 int _locked_by_me = FALSE; | |
6335 | |
6336 DW_MUTEX_UNLOCK; | |
86
a2b13e127d25
Make dw_color_depth() return the correct value on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
85
diff
changeset
|
6337 retval = gdk_visual_get_best_depth(); |
3 | 6338 DW_MUTEX_UNLOCK; |
6339 return retval; | |
6340 } | |
6341 | |
6342 /* | |
6343 * Sets the position of a given window (widget). | |
6344 * Parameters: | |
6345 * handle: Window (widget) handle. | |
6346 * x: X location from the bottom left. | |
6347 * y: Y location from the bottom left. | |
6348 */ | |
6349 void dw_window_set_pos(HWND handle, unsigned long x, unsigned long y) | |
6350 { | |
6351 int _locked_by_me = FALSE; | |
6352 | |
6353 DW_MUTEX_LOCK; | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
6354 if(handle && handle->window) |
3 | 6355 gdk_window_move(handle->window, x, y); |
6356 DW_MUTEX_UNLOCK; | |
6357 } | |
6358 | |
6359 /* | |
6360 * Sets the position and size of a given window (widget). | |
6361 * Parameters: | |
6362 * handle: Window (widget) handle. | |
6363 * x: X location from the bottom left. | |
6364 * y: Y location from the bottom left. | |
6365 * width: Width of the widget. | |
6366 * height: Height of the widget. | |
6367 */ | |
6368 void dw_window_set_pos_size(HWND handle, unsigned long x, unsigned long y, unsigned long width, unsigned long height) | |
6369 { | |
6370 int _locked_by_me = FALSE; | |
6371 | |
148
830f591c87f1
dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
147
diff
changeset
|
6372 if(!handle) |
830f591c87f1
dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
147
diff
changeset
|
6373 return; |
830f591c87f1
dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
147
diff
changeset
|
6374 |
830f591c87f1
dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
147
diff
changeset
|
6375 DW_MUTEX_LOCK; |
830f591c87f1
dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
147
diff
changeset
|
6376 if(GTK_IS_WINDOW(handle)) |
3 | 6377 { |
401
306ce9765a61
Fixes for new message box code. Also incorporated a fix from dw_window_set
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
399
diff
changeset
|
6378 dw_window_set_usize(handle, width, height); |
15
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
6379 gtk_widget_set_uposition(handle, x, y); |
3 | 6380 } |
148
830f591c87f1
dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
147
diff
changeset
|
6381 else if(handle->window) |
3 | 6382 { |
6383 gdk_window_resize(handle->window, width, height); | |
6384 gdk_window_move(handle->window, x, y); | |
6385 } | |
6386 DW_MUTEX_UNLOCK; | |
6387 } | |
6388 | |
6389 /* | |
6390 * Gets the position and size of a given window (widget). | |
6391 * Parameters: | |
6392 * handle: Window (widget) handle. | |
6393 * x: X location from the bottom left. | |
6394 * y: Y location from the bottom left. | |
6395 * width: Width of the widget. | |
6396 * height: Height of the widget. | |
6397 */ | |
6398 void dw_window_get_pos_size(HWND handle, ULONG *x, ULONG *y, ULONG *width, ULONG *height) | |
6399 { | |
6400 int _locked_by_me = FALSE; | |
6401 gint gx, gy, gwidth, gheight, gdepth; | |
6402 | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
6403 if(handle && handle->window) |
3 | 6404 { |
6405 DW_MUTEX_LOCK; | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
6406 |
3 | 6407 gdk_window_get_geometry(handle->window, &gx, &gy, &gwidth, &gheight, &gdepth); |
6408 gdk_window_get_root_origin(handle->window, &gx, &gy); | |
6409 if(x) | |
6410 *x = gx; | |
6411 if(y) | |
6412 *y = gy; | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6413 if(GTK_IS_WINDOW(handle)) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6414 { |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6415 if(width) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6416 *width = gwidth + _dw_border_width; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6417 if(height) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6418 *height = gheight + _dw_border_height; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6419 } |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6420 else |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6421 { |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6422 if(width) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6423 *width = gwidth; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6424 if(height) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6425 *height = gheight; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6426 } |
3 | 6427 DW_MUTEX_UNLOCK; |
6428 } | |
6429 } | |
6430 | |
6431 /* | |
6432 * Sets the style of a given window (widget). | |
6433 * Parameters: | |
6434 * handle: Window (widget) handle. | |
6435 * width: New width in pixels. | |
6436 * height: New height in pixels. | |
6437 */ | |
6438 void dw_window_set_style(HWND handle, unsigned long style, unsigned long mask) | |
6439 { | |
6440 GtkWidget *handle2 = handle; | |
6441 int _locked_by_me = FALSE; | |
6442 | |
6443 DW_MUTEX_LOCK; | |
6444 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
6445 { | |
6446 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
6447 if(tmp) | |
6448 handle2 = tmp; | |
6449 } | |
426
1f92eadea7d3
Allow dw_window_set_style() on status_text widgets.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
424
diff
changeset
|
6450 else if(GTK_IS_FRAME(handle)) |
1f92eadea7d3
Allow dw_window_set_style() on status_text widgets.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
424
diff
changeset
|
6451 { |
1f92eadea7d3
Allow dw_window_set_style() on status_text widgets.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
424
diff
changeset
|
6452 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_label"); |
1f92eadea7d3
Allow dw_window_set_style() on status_text widgets.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
424
diff
changeset
|
6453 if(tmp && GTK_IS_LABEL(tmp)) |
1f92eadea7d3
Allow dw_window_set_style() on status_text widgets.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
424
diff
changeset
|
6454 handle2 = tmp; |
1f92eadea7d3
Allow dw_window_set_style() on status_text widgets.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
424
diff
changeset
|
6455 } |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6456 if(GTK_IS_LABEL(handle2)) |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6457 { |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6458 if(style & DW_DT_CENTER || style & DW_DT_VCENTER) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6459 { |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6460 gfloat x, y; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6461 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6462 x = y = DW_LEFT; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6463 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6464 if(style & DW_DT_CENTER) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6465 x = DW_CENTER; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6466 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6467 if(style & DW_DT_VCENTER) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6468 y = DW_CENTER; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6469 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6470 gtk_misc_set_alignment(GTK_MISC(handle2), x, y); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6471 } |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6472 if(style & DW_DT_WORDBREAK) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6473 gtk_label_set_line_wrap(GTK_LABEL(handle), TRUE); |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6474 } |
3 | 6475 DW_MUTEX_UNLOCK; |
6476 } | |
6477 | |
6478 /* | |
6479 * Adds a new page to specified notebook. | |
6480 * Parameters: | |
6481 * handle: Window (widget) handle. | |
6482 * flags: Any additional page creation flags. | |
6483 * front: If TRUE page is added at the beginning. | |
6484 */ | |
6485 unsigned long dw_notebook_page_new(HWND handle, unsigned long flags, int front) | |
6486 { | |
6487 int z; | |
6488 int _locked_by_me = FALSE; | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6489 GtkWidget **pagearray; |
3 | 6490 |
6491 DW_MUTEX_LOCK; | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6492 pagearray = (GtkWidget **)gtk_object_get_data(GTK_OBJECT(handle), "_dw_pagearray"); |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6493 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6494 if(pagearray) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6495 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6496 for(z=0;z<256;z++) |
3 | 6497 { |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6498 if(!pagearray[z]) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6499 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6500 char text[100]; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6501 int num = z; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6502 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6503 if(front) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6504 num |= 1 << 16; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6505 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6506 sprintf(text, "_dw_page%d", z); |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6507 /* Save the real id and the creation flags */ |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6508 gtk_object_set_data(GTK_OBJECT(handle), text, (gpointer)num); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6509 DW_MUTEX_UNLOCK; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6510 return z; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6511 } |
3 | 6512 } |
15
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
6513 } |
3 | 6514 DW_MUTEX_UNLOCK; |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6515 |
3 | 6516 /* Hopefully this won't happen. */ |
6517 return 256; | |
6518 } | |
6519 | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6520 /* Return the physical page id from the logical page id */ |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6521 int _get_physical_page(HWND handle, unsigned long pageid) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6522 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6523 int z; |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6524 GtkWidget *thispage, **pagearray = gtk_object_get_data(GTK_OBJECT(handle), "_dw_pagearray"); |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6525 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6526 if(pagearray) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6527 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6528 for(z=0;z<256;z++) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6529 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6530 if((thispage = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), z))) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6531 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6532 if(thispage == pagearray[pageid]) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6533 return z; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6534 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6535 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6536 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6537 return 256; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6538 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6539 |
3 | 6540 /* |
6541 * Remove a page from a notebook. | |
6542 * Parameters: | |
6543 * handle: Handle to the notebook widget. | |
6544 * pageid: ID of the page to be destroyed. | |
6545 */ | |
6546 void dw_notebook_page_destroy(HWND handle, unsigned int pageid) | |
6547 { | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6548 int realpage, _locked_by_me = FALSE; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6549 GtkWidget **pagearray; |
3 | 6550 |
6551 DW_MUTEX_LOCK; | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6552 realpage = _get_physical_page(handle, pageid); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6553 if(realpage > -1 && realpage < 256) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6554 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6555 gtk_notebook_remove_page(GTK_NOTEBOOK(handle), realpage); |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6556 if((pagearray = gtk_object_get_data(GTK_OBJECT(handle), "_dw_pagearray"))) |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6557 pagearray[pageid] = NULL; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6558 } |
3 | 6559 DW_MUTEX_UNLOCK; |
6560 } | |
6561 | |
6562 /* | |
6563 * Queries the currently visible page ID. | |
6564 * Parameters: | |
6565 * handle: Handle to the notebook widget. | |
6566 */ | |
346
81fae15885d7
Implemented switch-page on OS/2, and changed the signal prototype to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
345
diff
changeset
|
6567 unsigned long dw_notebook_page_query(HWND handle) |
3 | 6568 { |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6569 int retval, phys; |
3 | 6570 int _locked_by_me = FALSE; |
6571 | |
6572 DW_MUTEX_LOCK; | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6573 phys = gtk_notebook_get_current_page(GTK_NOTEBOOK(handle)); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6574 retval = _get_logical_page(handle, phys); |
3 | 6575 DW_MUTEX_UNLOCK; |
6576 return retval; | |
6577 } | |
6578 | |
6579 /* | |
6580 * Sets the currently visibale page ID. | |
6581 * Parameters: | |
6582 * handle: Handle to the notebook widget. | |
6583 * pageid: ID of the page to be made visible. | |
6584 */ | |
6585 void dw_notebook_page_set(HWND handle, unsigned int pageid) | |
6586 { | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6587 int realpage, _locked_by_me = FALSE; |
3 | 6588 |
6589 DW_MUTEX_LOCK; | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6590 realpage = _get_physical_page(handle, pageid); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6591 if(realpage > -1 && realpage < 256) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6592 gtk_notebook_set_page(GTK_NOTEBOOK(handle), pageid); |
3 | 6593 DW_MUTEX_UNLOCK; |
6594 } | |
6595 | |
6596 | |
6597 /* | |
6598 * Sets the text on the specified notebook tab. | |
6599 * Parameters: | |
6600 * handle: Notebook handle. | |
6601 * pageid: Page ID of the tab to set. | |
6602 * text: Pointer to the text to set. | |
6603 */ | |
6604 void dw_notebook_page_set_text(HWND handle, unsigned long pageid, char *text) | |
6605 { | |
6606 GtkWidget *child; | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6607 int realpage, _locked_by_me = FALSE; |
3 | 6608 |
6609 DW_MUTEX_LOCK; | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6610 realpage = _get_physical_page(handle, pageid); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6611 if(realpage < 0 || realpage > 255) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6612 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6613 char ptext[100]; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6614 int num; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6615 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6616 sprintf(ptext, "_dw_page%d", (int)pageid); |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6617 num = (int)gtk_object_get_data(GTK_OBJECT(handle), ptext); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6618 realpage = 0xFF & num; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6619 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6620 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6621 if(realpage > -1 && realpage < 256) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6622 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6623 child = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), realpage); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6624 if(child) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6625 gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(handle), child, text); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6626 } |
3 | 6627 DW_MUTEX_UNLOCK; |
6628 } | |
6629 | |
6630 /* | |
6631 * Sets the text on the specified notebook tab status area. | |
6632 * Parameters: | |
6633 * handle: Notebook handle. | |
6634 * pageid: Page ID of the tab to set. | |
6635 * text: Pointer to the text to set. | |
6636 */ | |
6637 void dw_notebook_page_set_status_text(HWND handle, unsigned long pageid, char *text) | |
6638 { | |
6639 /* TODO (if possible) */ | |
6640 } | |
6641 | |
6642 /* | |
6643 * Packs the specified box into the notebook page. | |
6644 * Parameters: | |
6645 * handle: Handle to the notebook to be packed. | |
6646 * pageid: Page ID in the notebook which is being packed. | |
6647 * page: Box handle to be packed. | |
6648 */ | |
6649 void dw_notebook_pack(HWND handle, unsigned long pageid, HWND page) | |
6650 { | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6651 GtkWidget *label, *child, *oldlabel, **pagearray; |
15
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
6652 gchar *text = NULL; |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6653 int num, z, realpage = -1, pad, _locked_by_me = FALSE; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6654 char ptext[100]; |
3 | 6655 |
6656 DW_MUTEX_LOCK; | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6657 sprintf(ptext, "_dw_page%d", (int)pageid); |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6658 num = (int)gtk_object_get_data(GTK_OBJECT(handle), ptext); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6659 gtk_object_set_data(GTK_OBJECT(handle), ptext, NULL); |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6660 pagearray = (GtkWidget **)gtk_object_get_data(GTK_OBJECT(handle), "_dw_pagearray"); |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6661 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6662 if(!pagearray) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6663 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6664 DW_MUTEX_UNLOCK; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6665 return; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6666 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6667 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6668 /* The page already exists... so get it's current page */ |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6669 if(pagearray[pageid]) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6670 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6671 for(z=0;z<256;z++) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6672 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6673 child = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), z); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6674 if(child == pagearray[pageid]) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6675 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6676 oldlabel = gtk_notebook_get_tab_label(GTK_NOTEBOOK(handle), child); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6677 if(oldlabel) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6678 gtk_label_get(GTK_LABEL(oldlabel), &text); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6679 gtk_notebook_remove_page(GTK_NOTEBOOK(handle), z); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6680 realpage = z; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6681 break; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6682 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6683 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6684 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6685 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6686 pagearray[pageid] = page; |
15
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
6687 |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
6688 label = gtk_label_new(text ? text : ""); |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
6689 |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6690 if(GTK_IS_TABLE(page)) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6691 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6692 pad = (int)gtk_object_get_data(GTK_OBJECT(page), "_dw_boxpad"); |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6693 gtk_container_border_width(GTK_CONTAINER(page), pad); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6694 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6695 |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6696 if(realpage != -1) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6697 gtk_notebook_insert_page(GTK_NOTEBOOK(handle), page, label, realpage); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6698 else if(num & ~(0xFF)) |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6699 gtk_notebook_insert_page(GTK_NOTEBOOK(handle), page, label, 0); |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6700 else |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6701 gtk_notebook_insert_page(GTK_NOTEBOOK(handle), page, label, 256); |
3 | 6702 DW_MUTEX_UNLOCK; |
6703 } | |
6704 | |
6705 /* | |
6706 * Appends the specified text to the listbox's (or combobox) entry list. | |
6707 * Parameters: | |
6708 * handle: Handle to the listbox to be appended to. | |
6709 * text: Text to append into listbox. | |
6710 */ | |
6711 void dw_listbox_append(HWND handle, char *text) | |
6712 { | |
6713 GtkWidget *handle2 = handle; | |
6714 int _locked_by_me = FALSE; | |
6715 | |
6716 DW_MUTEX_LOCK; | |
6717 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
6718 { | |
6719 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
6720 if(tmp) | |
6721 handle2 = tmp; | |
6722 } | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6723 gtk_object_set_data(GTK_OBJECT(handle), "_dw_appending", (gpointer)1); |
3 | 6724 if(GTK_IS_LIST(handle2)) |
6725 { | |
6726 GtkWidget *list_item; | |
6727 GList *tmp; | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6728 char *font = (char *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_font"); |
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6729 GdkColor *fore = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle2), "_dw_foregdk"); |
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6730 GdkColor *back = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle2), "_dw_backgdk"); |
3 | 6731 |
6732 list_item=gtk_list_item_new_with_label(text); | |
6733 | |
6734 if(font) | |
6735 _set_font(GTK_LIST_ITEM(list_item)->item.bin.child, font); | |
6736 if(fore && back) | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
6737 _set_color(GTK_LIST_ITEM(list_item)->item.bin.child, |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
6738 DW_RGB(fore->red, fore->green, fore->blue), |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
6739 DW_RGB(back->red, back->green, back->blue)); |
3 | 6740 |
6741 tmp = g_list_append(NULL, list_item); | |
6742 gtk_widget_show(list_item); | |
6743 gtk_list_append_items(GTK_LIST(handle2),tmp); | |
6744 } | |
6745 else if(GTK_IS_COMBO(handle2)) | |
6746 { | |
6747 GList *tmp = (GList *)gtk_object_get_user_data(GTK_OBJECT(handle2)); | |
6748 char *addtext = strdup(text); | |
6749 | |
6750 if(addtext) | |
6751 { | |
6752 tmp = g_list_append(tmp, addtext); | |
6753 gtk_object_set_user_data(GTK_OBJECT(handle2), tmp); | |
6754 gtk_combo_set_popdown_strings(GTK_COMBO(handle2), tmp); | |
6755 } | |
6756 } | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6757 gtk_object_set_data(GTK_OBJECT(handle), "_dw_appending", NULL); |
3 | 6758 DW_MUTEX_UNLOCK; |
6759 } | |
6760 | |
6761 /* | |
6762 * Clears the listbox's (or combobox) list of all entries. | |
6763 * Parameters: | |
6764 * handle: Handle to the listbox to be cleared. | |
6765 */ | |
6766 void dw_listbox_clear(HWND handle) | |
6767 { | |
6768 GtkWidget *handle2 = handle; | |
6769 int _locked_by_me = FALSE; | |
6770 | |
6771 DW_MUTEX_LOCK; | |
6772 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
6773 { | |
6774 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
6775 if(tmp) | |
6776 handle2 = tmp; | |
6777 } | |
6778 if(GTK_IS_COMBO(handle2)) | |
6779 { | |
6780 GList *list, *tmp = (GList *)gtk_object_get_user_data(GTK_OBJECT(handle2)); | |
6781 | |
6782 if(tmp) | |
6783 { | |
6784 list = tmp; | |
6785 while(list) | |
6786 { | |
6787 if(list->data) | |
6788 free(list->data); | |
6789 list=list->next; | |
6790 } | |
6791 g_list_free(tmp); | |
6792 } | |
6793 gtk_object_set_user_data(GTK_OBJECT(handle2), NULL); | |
6794 } | |
6795 else if(GTK_IS_LIST(handle2)) | |
6796 { | |
6797 int count = dw_listbox_count(handle); | |
6798 | |
6799 gtk_list_clear_items(GTK_LIST(handle2), 0, count - 1); | |
6800 } | |
6801 DW_MUTEX_UNLOCK; | |
6802 } | |
6803 | |
6804 /* | |
6805 * Returns the listbox's item count. | |
6806 * Parameters: | |
6807 * handle: Handle to the listbox to be counted | |
6808 */ | |
6809 int dw_listbox_count(HWND handle) | |
6810 { | |
6811 GtkWidget *handle2 = handle; | |
6812 int retval = 0; | |
6813 int _locked_by_me = FALSE; | |
6814 | |
6815 DW_MUTEX_LOCK; | |
6816 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
6817 { | |
6818 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
6819 if(tmp) | |
6820 handle2 = tmp; | |
6821 } | |
6822 else if(GTK_IS_COMBO(handle)) | |
6823 { | |
6824 handle2 = GTK_COMBO(handle)->list; | |
6825 } | |
6826 if(GTK_IS_LIST(handle2)) | |
6827 { | |
6828 GList *list = GTK_LIST(handle2)->children; | |
6829 while(list) | |
6830 { | |
6831 list = list->next; | |
6832 retval++; | |
6833 } | |
6834 } | |
6835 DW_MUTEX_UNLOCK; | |
6836 return retval; | |
6837 } | |
6838 | |
6839 /* | |
6840 * Sets the topmost item in the viewport. | |
6841 * Parameters: | |
6842 * handle: Handle to the listbox to be cleared. | |
6843 * top: Index to the top item. | |
6844 */ | |
6845 void dw_listbox_set_top(HWND handle, int top) | |
6846 { | |
6847 GtkWidget *handle2 = handle; | |
6848 int _locked_by_me = FALSE; | |
6849 | |
6850 DW_MUTEX_LOCK; | |
6851 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
6852 { | |
6853 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
6854 if(tmp) | |
6855 handle2 = tmp; | |
6856 } | |
6857 if(GTK_IS_LIST(handle2)) | |
6858 { | |
6859 int count = dw_listbox_count(handle); | |
6860 GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(handle)); | |
6861 float pos, ratio; | |
6862 | |
6863 if(count) | |
6864 { | |
6865 ratio = (float)top/(float)count; | |
6866 | |
6867 pos = (ratio * (float)(adj->upper - adj->lower)) + adj->lower; | |
6868 | |
6869 gtk_adjustment_set_value(adj, pos); | |
6870 } | |
6871 } | |
6872 DW_MUTEX_UNLOCK; | |
6873 } | |
6874 | |
6875 /* | |
6876 * Copies the given index item's text into buffer. | |
6877 * Parameters: | |
6878 * handle: Handle to the listbox to be queried. | |
6879 * index: Index into the list to be queried. | |
6880 * buffer: Buffer where text will be copied. | |
6881 * length: Length of the buffer (including NULL). | |
6882 */ | |
6883 void dw_listbox_query_text(HWND handle, unsigned int index, char *buffer, unsigned int length) | |
6884 { | |
6885 GtkWidget *handle2 = handle; | |
6886 int _locked_by_me = FALSE; | |
6887 | |
6888 DW_MUTEX_LOCK; | |
6889 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
6890 { | |
6891 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
6892 if(tmp) | |
6893 handle2 = tmp; | |
6894 } | |
6895 else if(GTK_IS_COMBO(handle)) | |
6896 { | |
6897 handle2 = GTK_COMBO(handle)->list; | |
6898 } | |
6899 if(GTK_IS_LIST(handle2)) | |
6900 { | |
6901 int counter = 0; | |
6902 GList *list = GTK_LIST(handle2)->children; | |
6903 | |
6904 while(list) | |
6905 { | |
6906 if(counter == index) | |
6907 { | |
6908 gchar *text = ""; | |
6909 | |
6910 if(GTK_IS_LIST_ITEM(list->data)) | |
6911 { | |
6912 GtkListItem *li = GTK_LIST_ITEM(list->data); | |
6913 | |
6914 if(GTK_IS_ITEM(&(li->item))) | |
6915 { | |
6916 GtkItem *i = &(li->item); | |
6917 | |
6918 if(GTK_IS_BIN(&(i->bin))) | |
6919 { | |
6920 GtkBin *b = &(i->bin); | |
6921 | |
6922 if(GTK_IS_LABEL(b->child)) | |
6923 gtk_label_get(GTK_LABEL(b->child), &text); | |
6924 } | |
6925 } | |
6926 } | |
6927 else if(GTK_IS_COMBO(handle) && list->data) | |
6928 text = (gchar *)list->data; | |
6929 | |
6930 strncpy(buffer, (char *)text, length); | |
6931 break; | |
6932 } | |
6933 list = list->next; | |
6934 counter++; | |
6935 } | |
6936 } | |
6937 DW_MUTEX_UNLOCK; | |
6938 } | |
6939 | |
6940 /* | |
6941 * Sets the text of a given listbox entry. | |
6942 * Parameters: | |
6943 * handle: Handle to the listbox to be queried. | |
6944 * index: Index into the list to be queried. | |
6945 * buffer: Buffer where text will be copied. | |
6946 */ | |
6947 void dw_listbox_set_text(HWND handle, unsigned int index, char *buffer) | |
6948 { | |
6949 GtkWidget *handle2 = handle; | |
6950 int _locked_by_me = FALSE; | |
6951 | |
6952 DW_MUTEX_LOCK; | |
6953 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
6954 { | |
6955 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
6956 if(tmp) | |
6957 handle2 = tmp; | |
6958 } | |
6959 else if(GTK_IS_COMBO(handle)) | |
6960 { | |
6961 handle2 = GTK_COMBO(handle)->list; | |
6962 } | |
6963 if(GTK_IS_LIST(handle2)) | |
6964 { | |
6965 int counter = 0; | |
6966 GList *list = GTK_LIST(handle2)->children; | |
6967 | |
6968 while(list) | |
6969 { | |
6970 if(counter == index) | |
6971 { | |
6972 | |
6973 if(GTK_IS_LIST_ITEM(list->data)) | |
6974 { | |
6975 GtkListItem *li = GTK_LIST_ITEM(list->data); | |
6976 | |
6977 if(GTK_IS_ITEM(&(li->item))) | |
6978 { | |
6979 GtkItem *i = &(li->item); | |
6980 | |
6981 if(GTK_IS_BIN(&(i->bin))) | |
6982 { | |
6983 GtkBin *b = &(i->bin); | |
6984 | |
6985 if(GTK_IS_LABEL(b->child)) | |
6986 gtk_label_set_text(GTK_LABEL(b->child), buffer); | |
6987 } | |
6988 } | |
6989 } | |
6990 else if(GTK_IS_COMBO(handle)) | |
6991 { | |
6992 if(list->data) | |
6993 g_free(list->data); | |
6994 list->data = g_strdup(buffer); | |
6995 } | |
6996 break; | |
6997 } | |
6998 list = list->next; | |
6999 counter++; | |
7000 } | |
7001 } | |
7002 DW_MUTEX_UNLOCK; | |
7003 } | |
7004 | |
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:
145
diff
changeset
|
7005 #if GTK_MAJOR_VERSION < 2 |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7006 /* Check if a GList item is in another GList */ |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
7007 static int _dw_in_list(GList *item, GList *list) |
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:
145
diff
changeset
|
7008 { |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7009 while(list) |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7010 { |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7011 if(list->data == item->data) |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7012 return TRUE; |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7013 |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7014 list = list->next; |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7015 } |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7016 return FALSE; |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7017 } |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7018 #endif |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7019 |
3 | 7020 /* |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7021 * Returns the index to the current selected item or -1 when done. |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7022 * Parameters: |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7023 * handle: Handle to the listbox to be queried. |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7024 * where: Either the previous return or -1 to restart. |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7025 */ |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7026 int dw_listbox_selected_multi(HWND handle, int where) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7027 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7028 GtkWidget *handle2 = handle; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7029 int retval = DW_LIT_NONE; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7030 int _locked_by_me = FALSE; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7031 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7032 DW_MUTEX_LOCK; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7033 if(GTK_IS_SCROLLED_WINDOW(handle)) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7034 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7035 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7036 if(tmp) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7037 handle2 = tmp; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7038 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7039 if(GTK_IS_LIST(handle2)) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7040 { |
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:
145
diff
changeset
|
7041 #if GTK_MAJOR_VERSION > 1 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7042 int counter = 0; |
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:
145
diff
changeset
|
7043 GList *list = GTK_LIST(handle2)->children; |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7044 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7045 while(list) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7046 { |
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:
145
diff
changeset
|
7047 GtkItem *item = (GtkItem *)list->data; |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7048 |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7049 if(item && |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7050 item->bin.container.widget.state == GTK_STATE_SELECTED |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7051 && counter > where) |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7052 { |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7053 retval = counter; |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7054 break; |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7055 } |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7056 |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7057 |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7058 list = list->next; |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7059 counter++; |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7060 } |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7061 #else |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7062 int counter = 0; |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7063 GList *list = GTK_LIST(handle2)->children; |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7064 |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7065 while(list) |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7066 { |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7067 if(counter > where && _dw_in_list(list, GTK_LIST(handle2)->selection)) |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7068 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7069 retval = counter; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7070 break; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7071 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7072 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7073 list = list->next; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7074 counter++; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7075 } |
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:
145
diff
changeset
|
7076 #endif |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7077 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7078 DW_MUTEX_UNLOCK; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7079 return retval; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7080 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7081 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7082 /* |
3 | 7083 * Returns the index to the item in the list currently selected. |
7084 * Parameters: | |
7085 * handle: Handle to the listbox to be queried. | |
7086 */ | |
7087 unsigned int dw_listbox_selected(HWND handle) | |
7088 { | |
7089 GtkWidget *handle2 = handle; | |
7090 int retval = DW_LIT_NONE; | |
7091 int _locked_by_me = FALSE; | |
7092 | |
7093 DW_MUTEX_LOCK; | |
7094 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
7095 { | |
7096 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
7097 if(tmp) | |
7098 handle2 = tmp; | |
7099 } | |
7100 else if(GTK_IS_COMBO(handle)) | |
7101 { | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7102 retval = (unsigned int)gtk_object_get_data(GTK_OBJECT(handle), "_dw_item"); |
3 | 7103 DW_MUTEX_UNLOCK; |
7104 return retval; | |
7105 } | |
7106 if(GTK_IS_LIST(handle2)) | |
7107 { | |
7108 int counter = 0; | |
7109 GList *list = GTK_LIST(handle2)->children; | |
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:
145
diff
changeset
|
7110 #if GTK_MAJOR_VERSION > 1 |
423
c1c75e363a91
Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
422
diff
changeset
|
7111 |
c1c75e363a91
Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
422
diff
changeset
|
7112 while(list) |
c1c75e363a91
Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
422
diff
changeset
|
7113 { |
c1c75e363a91
Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
422
diff
changeset
|
7114 GtkItem *item = (GtkItem *)list->data; |
c1c75e363a91
Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
422
diff
changeset
|
7115 |
c1c75e363a91
Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
422
diff
changeset
|
7116 if(item && item->bin.container.widget.state == GTK_STATE_SELECTED) |
c1c75e363a91
Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
422
diff
changeset
|
7117 { |
c1c75e363a91
Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
422
diff
changeset
|
7118 retval = counter; |
c1c75e363a91
Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
422
diff
changeset
|
7119 break; |
c1c75e363a91
Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
422
diff
changeset
|
7120 } |
c1c75e363a91
Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
422
diff
changeset
|
7121 |
c1c75e363a91
Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
422
diff
changeset
|
7122 list = list->next; |
c1c75e363a91
Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
422
diff
changeset
|
7123 counter++; |
c1c75e363a91
Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
422
diff
changeset
|
7124 } |
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:
145
diff
changeset
|
7125 #else |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7126 GList *selection = GTK_LIST(handle2)->selection; |
423
c1c75e363a91
Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
422
diff
changeset
|
7127 |
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:
145
diff
changeset
|
7128 if(selection) |
3 | 7129 { |
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:
145
diff
changeset
|
7130 while(list) |
3 | 7131 { |
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:
145
diff
changeset
|
7132 if(list->data == selection->data) |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7133 { |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7134 retval = counter; |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7135 break; |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7136 } |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7137 |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7138 list = list->next; |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7139 counter++; |
3 | 7140 } |
7141 } | |
423
c1c75e363a91
Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
422
diff
changeset
|
7142 #endif |
3 | 7143 } |
7144 DW_MUTEX_UNLOCK; | |
7145 return retval; | |
7146 } | |
7147 | |
7148 /* | |
7149 * Sets the selection state of a given index. | |
7150 * Parameters: | |
7151 * handle: Handle to the listbox to be set. | |
7152 * index: Item index. | |
7153 * state: TRUE if selected FALSE if unselected. | |
7154 */ | |
7155 void dw_listbox_select(HWND handle, int index, int state) | |
7156 { | |
7157 GtkWidget *handle2 = handle; | |
7158 int _locked_by_me = FALSE; | |
7159 | |
7160 DW_MUTEX_LOCK; | |
7161 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
7162 { | |
7163 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
7164 if(tmp) | |
7165 handle2 = tmp; | |
7166 } | |
7167 else if(GTK_IS_COMBO(handle)) | |
7168 { | |
7169 handle2 = GTK_COMBO(handle)->list; | |
7170 } | |
7171 if(GTK_IS_LIST(handle2)) | |
7172 { | |
7173 if(state) | |
7174 gtk_list_select_item(GTK_LIST(handle2), index); | |
7175 else | |
7176 gtk_list_unselect_item(GTK_LIST(handle2), index); | |
7177 } | |
7178 DW_MUTEX_UNLOCK; | |
7179 } | |
7180 | |
7181 /* | |
7182 * Deletes the item with given index from the list. | |
7183 * Parameters: | |
7184 * handle: Handle to the listbox to be set. | |
7185 * index: Item index. | |
7186 */ | |
7187 void dw_listbox_delete(HWND handle, int index) | |
7188 { | |
7189 GtkWidget *handle2 = handle; | |
7190 int _locked_by_me = FALSE; | |
7191 | |
7192 DW_MUTEX_LOCK; | |
7193 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
7194 { | |
7195 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
7196 if(tmp) | |
7197 handle2 = tmp; | |
7198 } | |
7199 else if(GTK_IS_COMBO(handle)) | |
7200 { | |
7201 handle2 = GTK_COMBO(handle)->list; | |
7202 } | |
7203 if(GTK_IS_LIST(handle2)) | |
7204 gtk_list_clear_items(GTK_LIST(handle2), index, index); | |
7205 DW_MUTEX_UNLOCK; | |
7206 } | |
7207 | |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7208 /* Reposition the bar according to the percentage */ |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
7209 static gint _splitbar_size_allocate(GtkWidget *widget, GtkAllocation *event, gpointer data) |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7210 { |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7211 float *percent = (float *)gtk_object_get_data(GTK_OBJECT(widget), "_dw_percent"); |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7212 int lastwidth = (int)gtk_object_get_data(GTK_OBJECT(widget), "_dw_lastwidth"); |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7213 int lastheight = (int)gtk_object_get_data(GTK_OBJECT(widget), "_dw_lastheight"); |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7214 |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7215 /* Prevent infinite recursion ;) */ |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7216 if(!percent || (lastwidth == event->width && lastheight == event->height)) |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
7217 return FALSE; |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7218 |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7219 lastwidth = event->width; lastheight = event->height; |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7220 |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7221 gtk_object_set_data(GTK_OBJECT(widget), "_dw_lastwidth", (gpointer)lastwidth); |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7222 gtk_object_set_data(GTK_OBJECT(widget), "_dw_lastheight", (gpointer)lastheight); |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7223 |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7224 if(GTK_IS_HPANED(widget)) |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7225 gtk_paned_set_position(GTK_PANED(widget), (int)(event->width * (*percent / 100.0))); |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7226 if(GTK_IS_VPANED(widget)) |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7227 gtk_paned_set_position(GTK_PANED(widget), (int)(event->height * (*percent / 100.0))); |
145
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7228 gtk_object_set_data(GTK_OBJECT(widget), "_dw_waiting", NULL); |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
7229 return FALSE; |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7230 } |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7231 |
122
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
7232 #if GTK_MAJOR_VERSION > 1 |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7233 /* Figure out the new percentage */ |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
7234 static void _splitbar_accept_position(GObject *object, GParamSpec *pspec, gpointer data) |
145
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7235 { |
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7236 GtkWidget *widget = (GtkWidget *)data; |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7237 float *percent = (float *)gtk_object_get_data(GTK_OBJECT(widget), "_dw_percent"); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7238 int size = 0, position = gtk_paned_get_position(GTK_PANED(widget)); |
122
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
7239 |
145
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7240 if(!percent || gtk_object_get_data(GTK_OBJECT(widget), "_dw_waiting")) |
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7241 return; |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7242 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7243 if(GTK_IS_VPANED(widget)) |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7244 size = widget->allocation.height; |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7245 else if(GTK_IS_HPANED(widget)) |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7246 size = widget->allocation.width; |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7247 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7248 if(size > 0) |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7249 *percent = ((float)(position * 100) / (float)size); |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7250 } |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7251 #endif |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7252 |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7253 /* |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7254 * Creates a splitbar window (widget) with given parameters. |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7255 * Parameters: |
283
54aafc134652
BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
282
diff
changeset
|
7256 * type: Value can be DW_VERT or DW_HORZ. |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7257 * topleft: Handle to the window to be top or left. |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7258 * bottomright: Handle to the window to be bottom or right. |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7259 * Returns: |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7260 * A handle to a splitbar window or NULL on failure. |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7261 */ |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7262 HWND dw_splitbar_new(int type, HWND topleft, HWND bottomright, unsigned long id) |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7263 { |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7264 GtkWidget *tmp = NULL; |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7265 int _locked_by_me = FALSE; |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7266 float *percent = malloc(sizeof(float)); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7267 |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7268 DW_MUTEX_LOCK; |
283
54aafc134652
BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
282
diff
changeset
|
7269 if(type == DW_HORZ) |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7270 tmp = gtk_hpaned_new(); |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7271 else |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7272 tmp = gtk_vpaned_new(); |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7273 gtk_paned_add1(GTK_PANED(tmp), topleft); |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7274 gtk_paned_add2(GTK_PANED(tmp), bottomright); |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7275 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7276 *percent = 50.0; |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7277 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_percent", (gpointer)percent); |
145
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7278 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_waiting", (gpointer)1); |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7279 gtk_signal_connect(GTK_OBJECT(tmp), "size-allocate", GTK_SIGNAL_FUNC(_splitbar_size_allocate), NULL); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7280 #if GTK_MAJOR_VERSION > 1 |
145
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7281 g_signal_connect(G_OBJECT(tmp), "notify::position", (GCallback)_splitbar_accept_position, (gpointer)tmp); |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7282 #else |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7283 gtk_paned_set_handle_size(GTK_PANED(tmp), 3); |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7284 #endif |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7285 gtk_widget_show(tmp); |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7286 DW_MUTEX_UNLOCK; |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7287 return tmp; |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7288 } |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7289 |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7290 /* |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7291 * Sets the position of a splitbar (pecentage). |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7292 * Parameters: |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7293 * handle: The handle to the splitbar returned by dw_splitbar_new(). |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7294 */ |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7295 void dw_splitbar_set(HWND handle, float percent) |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7296 { |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7297 float *mypercent = (float *)dw_window_get_data(handle, "_dw_percent"); |
145
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7298 int size = 0, position; |
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7299 |
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7300 if(GTK_IS_VPANED(handle)) |
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7301 size = handle->allocation.height; |
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7302 else if(GTK_IS_HPANED(handle)) |
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7303 size = handle->allocation.width; |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7304 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7305 if(mypercent) |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7306 *mypercent = percent; |
145
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7307 |
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7308 if(size > 10) |
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7309 { |
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7310 position = (int)((float)size * (percent / 100.0)); |
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7311 |
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7312 gtk_paned_set_position(GTK_PANED(handle), position); |
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7313 } |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7314 } |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7315 |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7316 /* |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7317 * Gets the position of a splitbar (pecentage). |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7318 * Parameters: |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7319 * handle: The handle to the splitbar returned by dw_splitbar_new(). |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7320 */ |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7321 float dw_splitbar_get(HWND handle) |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7322 { |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7323 float *percent = (float *)dw_window_get_data(handle, "_dw_percent"); |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7324 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7325 if(percent) |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7326 return *percent; |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7327 return 0.0; |
3 | 7328 } |
7329 | |
7330 /* | |
7331 * Pack windows (widgets) into a box from the start (or top). | |
7332 * Parameters: | |
7333 * box: Window handle of the box to be packed into. | |
7334 * item: Window handle of the item to be back. | |
7335 * width: Width in pixels of the item or -1 to be self determined. | |
7336 * height: Height in pixels of the item or -1 to be self determined. | |
7337 * hsize: TRUE if the window (widget) should expand horizontally to fill space given. | |
7338 * vsize: TRUE if the window (widget) should expand vertically to fill space given. | |
7339 * pad: Number of pixels of padding around the item. | |
7340 */ | |
7341 void dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) | |
7342 { | |
7343 int _locked_by_me = FALSE; | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
7344 GtkWidget *tmp; |
3 | 7345 |
7346 if(!box) | |
7347 return; | |
7348 | |
7349 DW_MUTEX_LOCK; | |
7350 | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7351 if((tmp = gtk_object_get_data(GTK_OBJECT(box), "_dw_boxhandle"))) |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
7352 box = tmp; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
7353 |
3 | 7354 if(!item) |
7355 { | |
7356 item = gtk_label_new(""); | |
7357 gtk_widget_show(item); | |
7358 } | |
7359 | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7360 if(GTK_IS_TABLE(box)) |
3 | 7361 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7362 int boxcount = (int)gtk_object_get_data(GTK_OBJECT(box), "_dw_boxcount"); |
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7363 int boxtype = (int)gtk_object_get_data(GTK_OBJECT(box), "_dw_boxtype"); |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7364 int x, y; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7365 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7366 /* If the item being packed is a box, then we use it's padding |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7367 * instead of the padding specified on the pack line, this is |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7368 * due to a bug in the OS/2 and Win32 renderer and a limitation |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7369 * of the GtkTable class. |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7370 */ |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7371 if(GTK_IS_TABLE(item)) |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7372 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7373 GtkWidget *eventbox = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(item), "_dw_eventbox"); |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7374 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7375 if(eventbox) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7376 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7377 gtk_container_add(GTK_CONTAINER(eventbox), item); |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7378 pad = (int)gtk_object_get_data(GTK_OBJECT(item), "_dw_boxpad"); |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7379 item = eventbox; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7380 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7381 } |
438
fac2afe7bda3
Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
429
diff
changeset
|
7382 else |
fac2afe7bda3
Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
429
diff
changeset
|
7383 { |
fac2afe7bda3
Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
429
diff
changeset
|
7384 /* Only show warning if item is not a box */ |
fac2afe7bda3
Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
429
diff
changeset
|
7385 if ( width == 0 && hsize == FALSE ) |
fac2afe7bda3
Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
429
diff
changeset
|
7386 dw_messagebox("dw_box_pack_start()", DW_MB_OK|DW_MB_ERROR, "Width and expand Horizonal both unset for box: %x item: %x",box,item); |
fac2afe7bda3
Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
429
diff
changeset
|
7387 if ( height == 0 && vsize == FALSE ) |
fac2afe7bda3
Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
429
diff
changeset
|
7388 dw_messagebox("dw_box_pack_start()", DW_MB_OK|DW_MB_ERROR, "Height and expand Vertical both unset for box: %x item: %x",box,item); |
fac2afe7bda3
Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
429
diff
changeset
|
7389 } |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7390 |
283
54aafc134652
BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
282
diff
changeset
|
7391 if(boxtype == DW_VERT) |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7392 { |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7393 x = 0; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7394 y = boxcount; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7395 gtk_table_resize(GTK_TABLE(box), boxcount + 1, 1); |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7396 } |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7397 else |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7398 { |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7399 x = boxcount; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7400 y = 0; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7401 gtk_table_resize(GTK_TABLE(box), 1, boxcount + 1); |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7402 } |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7403 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7404 gtk_table_attach(GTK_TABLE(box), item, x, x + 1, y, y + 1, hsize ? DW_EXPAND : 0, vsize ? DW_EXPAND : 0, pad, pad); |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7405 gtk_object_set_data(GTK_OBJECT(box), "_dw_boxcount", (gpointer)boxcount + 1); |
3 | 7406 gtk_widget_set_usize(item, width, height); |
7407 if(GTK_IS_RADIO_BUTTON(item)) | |
7408 { | |
7409 GSList *group; | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7410 GtkWidget *groupstart = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(box), "_dw_group"); |
3 | 7411 |
7412 if(groupstart) | |
7413 { | |
7414 group = gtk_radio_button_group(GTK_RADIO_BUTTON(groupstart)); | |
7415 gtk_radio_button_set_group(GTK_RADIO_BUTTON(item), group); | |
7416 } | |
7417 else | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7418 gtk_object_set_data(GTK_OBJECT(box), "_dw_group", (gpointer)item); |
3 | 7419 } |
7420 } | |
7421 else | |
7422 { | |
7423 GtkWidget *vbox = gtk_vbox_new(FALSE, 0); | |
7424 | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7425 if(GTK_IS_TABLE(item)) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7426 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7427 GtkWidget *eventbox = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(item), "_dw_eventbox"); |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7428 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7429 if(eventbox) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7430 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7431 gtk_container_add(GTK_CONTAINER(eventbox), item); |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7432 pad = (int)gtk_object_get_data(GTK_OBJECT(item), "_dw_boxpad"); |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7433 item = eventbox; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7434 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7435 } |
438
fac2afe7bda3
Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
429
diff
changeset
|
7436 else |
fac2afe7bda3
Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
429
diff
changeset
|
7437 { |
fac2afe7bda3
Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
429
diff
changeset
|
7438 /* Only show warning if item is not a box */ |
fac2afe7bda3
Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
429
diff
changeset
|
7439 if ( width == 0 && hsize == FALSE ) |
fac2afe7bda3
Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
429
diff
changeset
|
7440 dw_messagebox("dw_box_pack_start()", DW_MB_OK|DW_MB_ERROR, "Width and expand Horizonal both unset for box: %x item: %x",box,item); |
fac2afe7bda3
Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
429
diff
changeset
|
7441 if ( height == 0 && vsize == FALSE ) |
fac2afe7bda3
Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
429
diff
changeset
|
7442 dw_messagebox("dw_box_pack_start()", DW_MB_OK|DW_MB_ERROR, "Height and expand Vertical both unset for box: %x item: %x",box,item); |
fac2afe7bda3
Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
429
diff
changeset
|
7443 } |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7444 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7445 gtk_container_border_width(GTK_CONTAINER(box), pad); |
3 | 7446 gtk_container_add(GTK_CONTAINER(box), vbox); |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7447 gtk_box_pack_end(GTK_BOX(vbox), item, TRUE, TRUE, 0); |
3 | 7448 gtk_widget_show(vbox); |
7449 | |
7450 gtk_widget_set_usize(item, width, height); | |
7451 gtk_object_set_user_data(GTK_OBJECT(box), vbox); | |
7452 } | |
7453 DW_MUTEX_UNLOCK; | |
7454 } | |
7455 | |
7456 /* | |
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
|
7457 * 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
|
7458 * 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
|
7459 * 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
|
7460 * 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
|
7461 */ |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
7462 void dw_window_default(HWND window, HWND 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
|
7463 { |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
7464 int _locked_by_me = FALSE; |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
7465 |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
7466 if(!window) |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
7467 return; |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
7468 |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
7469 DW_MUTEX_LOCK; |
273
95bfcd2deb94
Slight change to get it to work on GTK 2.x, although there is a momentary
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
272
diff
changeset
|
7470 gtk_object_set_data(GTK_OBJECT(window), "_dw_defaultitem", (gpointer)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
|
7471 DW_MUTEX_UNLOCK; |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
7472 } |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
7473 |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
7474 /* |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7475 * 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
|
7476 * Parameters: |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7477 * 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
|
7478 * 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
|
7479 */ |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7480 void dw_window_click_default(HWND window, HWND next) |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7481 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7482 int _locked_by_me = FALSE; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7483 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7484 if(!window) |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7485 return; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7486 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7487 DW_MUTEX_LOCK; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7488 gtk_signal_connect(GTK_OBJECT(window), "key_press_event", GTK_SIGNAL_FUNC(_default_key_press_event), next); |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7489 DW_MUTEX_UNLOCK; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7490 } |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7491 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7492 /* |
3 | 7493 * Returns some information about the current operating environment. |
7494 * Parameters: | |
7495 * env: Pointer to a DWEnv struct. | |
7496 */ | |
7497 void dw_environment_query(DWEnv *env) | |
7498 { | |
7499 struct utsname name; | |
7500 char tempbuf[100]; | |
7501 int len, z; | |
7502 | |
7503 uname(&name); | |
7504 strcpy(env->osName, name.sysname); | |
7505 strcpy(tempbuf, name.release); | |
7506 | |
7507 env->MajorBuild = env->MinorBuild = 0; | |
7508 | |
7509 len = strlen(tempbuf); | |
7510 | |
15
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
7511 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
|
7512 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
|
7513 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
|
7514 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
|
7515 env->DWSubVersion = DW_SUB_VERSION; |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
7516 |
3 | 7517 for(z=1;z<len;z++) |
7518 { | |
7519 if(tempbuf[z] == '.') | |
7520 { | |
7521 tempbuf[z] = '\0'; | |
7522 env->MajorVersion = atoi(&tempbuf[z-1]); | |
7523 env->MinorVersion = atoi(&tempbuf[z+1]); | |
7524 return; | |
7525 } | |
7526 } | |
7527 env->MajorVersion = atoi(tempbuf); | |
7528 env->MinorVersion = 0; | |
7529 } | |
7530 | |
7531 /* Internal function to handle the file OK press */ | |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
7532 static gint _gtk_file_ok(GtkWidget *widget, DWDialog *dwwait) |
3 | 7533 { |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7534 #if GTK_MAJOR_VERSION > 1 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7535 const char *tmp; |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7536 #else |
3 | 7537 char *tmp; |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7538 #endif |
214
0e98514a3905
Applied patch from Mark Hessling to prevent the return buffer from the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
208
diff
changeset
|
7539 char *tmpdup=NULL; |
3 | 7540 |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
7541 if(!dwwait) |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
7542 return FALSE; |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
7543 |
214
0e98514a3905
Applied patch from Mark Hessling to prevent the return buffer from the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
208
diff
changeset
|
7544 if((tmp = gtk_file_selection_get_filename(GTK_FILE_SELECTION(dwwait->data)))) |
0e98514a3905
Applied patch from Mark Hessling to prevent the return buffer from the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
208
diff
changeset
|
7545 tmpdup = strdup(tmp); |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
7546 gtk_widget_destroy(GTK_WIDGET(dwwait->data)); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
7547 _dw_file_active = 0; |
214
0e98514a3905
Applied patch from Mark Hessling to prevent the return buffer from the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
208
diff
changeset
|
7548 dw_dialog_dismiss(dwwait, (void *)tmpdup); |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
7549 return FALSE; |
3 | 7550 } |
7551 | |
7552 /* Internal function to handle the file Cancel press */ | |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
7553 static gint _gtk_file_cancel(GtkWidget *widget, DWDialog *dwwait) |
3 | 7554 { |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
7555 if(!dwwait) |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
7556 return FALSE; |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
7557 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
7558 gtk_widget_destroy(GTK_WIDGET(dwwait->data)); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
7559 _dw_file_active = 0; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
7560 dw_dialog_dismiss(dwwait, NULL); |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
7561 return FALSE; |
3 | 7562 } |
7563 | |
7564 /* | |
7565 * Opens a file dialog and queries user selection. | |
7566 * Parameters: | |
7567 * title: Title bar text for dialog. | |
7568 * defpath: The default path of the open dialog. | |
7569 * ext: Default file extention. | |
7570 * flags: DW_FILE_OPEN or DW_FILE_SAVE. | |
7571 * Returns: | |
7572 * NULL on error. A malloced buffer containing | |
7573 * the file path on success. | |
7574 * | |
7575 */ | |
7576 char *dw_file_browse(char *title, char *defpath, char *ext, int flags) | |
7577 { | |
7578 GtkWidget *filew; | |
7579 int _locked_by_me = FALSE; | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
7580 DWDialog *dwwait; |
3 | 7581 |
7582 DW_MUTEX_LOCK; | |
7583 | |
7584 /* The DW mutex should be sufficient for | |
7585 * insuring no thread changes this unknowingly. | |
7586 */ | |
7587 if(_dw_file_active) | |
7588 { | |
7589 DW_MUTEX_UNLOCK; | |
7590 return NULL; | |
7591 } | |
7592 | |
7593 _dw_file_active = 1; | |
7594 | |
7595 filew = gtk_file_selection_new(title); | |
7596 | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
7597 dwwait = dw_dialog_new((void *)filew); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
7598 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
7599 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filew)->ok_button), "clicked", (GtkSignalFunc) _gtk_file_ok, dwwait); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
7600 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filew)->cancel_button), "clicked", (GtkSignalFunc) _gtk_file_cancel, dwwait); |
3 | 7601 |
7602 if(defpath) | |
7603 gtk_file_selection_set_filename(GTK_FILE_SELECTION(filew), defpath); | |
7604 | |
7605 gtk_widget_show(filew); | |
7606 | |
7607 DW_MUTEX_UNLOCK; | |
7608 | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
7609 return (char *)dw_dialog_wait(dwwait); |
3 | 7610 } |
7611 | |
7612 | |
7613 /* | |
7614 * Execute and external program in a seperate session. | |
7615 * Parameters: | |
7616 * program: Program name with optional path. | |
7617 * type: Either DW_EXEC_CON or DW_EXEC_GUI. | |
7618 * params: An array of pointers to string arguements. | |
7619 * Returns: | |
7620 * -1 on error. | |
7621 */ | |
7622 int dw_exec(char *program, int type, char **params) | |
7623 { | |
7624 int ret = -1; | |
7625 | |
7626 if((ret = fork()) == 0) | |
7627 { | |
7628 int i; | |
7629 | |
7630 for (i = 3; i < 256; i++) | |
7631 close(i); | |
7632 setsid(); | |
7633 if(type == DW_EXEC_GUI) | |
7634 { | |
7635 execvp(program, params); | |
7636 } | |
7637 else if(type == DW_EXEC_CON) | |
7638 { | |
7639 char **tmpargs; | |
7640 | |
7641 if(!params) | |
7642 { | |
7643 tmpargs = malloc(sizeof(char *)); | |
7644 tmpargs[0] = NULL; | |
7645 } | |
7646 else | |
7647 { | |
7648 int z = 0; | |
7649 | |
7650 while(params[z]) | |
7651 { | |
7652 z++; | |
7653 } | |
7654 tmpargs = malloc(sizeof(char *)*(z+3)); | |
7655 z=0; | |
7656 tmpargs[0] = "xterm"; | |
7657 tmpargs[1] = "-e"; | |
7658 while(params[z]) | |
7659 { | |
7660 tmpargs[z+2] = params[z]; | |
7661 z++; | |
7662 } | |
7663 tmpargs[z+2] = NULL; | |
7664 } | |
7665 execvp("xterm", tmpargs); | |
7666 free(tmpargs); | |
7667 } | |
7668 /* If we got here exec failed */ | |
7669 _exit(-1); | |
7670 } | |
7671 return ret; | |
7672 } | |
7673 | |
7674 /* | |
7675 * Loads a web browser pointed at the given URL. | |
7676 * Parameters: | |
7677 * url: Uniform resource locator. | |
7678 */ | |
7679 int dw_browse(char *url) | |
7680 { | |
7681 /* Is there a way to find the webbrowser in Unix? */ | |
7682 char *execargs[3], *browser = "netscape"; | |
7683 | |
7684 execargs[0] = browser; | |
7685 execargs[1] = url; | |
7686 execargs[2] = NULL; | |
7687 | |
7688 return dw_exec(browser, DW_EXEC_GUI, execargs); | |
7689 } | |
7690 | |
7691 /* | |
7692 * Returns a pointer to a static buffer which containes the | |
7693 * current user directory. Or the root directory (C:\ on | |
7694 * OS/2 and Windows). | |
7695 */ | |
7696 char *dw_user_dir(void) | |
7697 { | |
7698 static char _user_dir[1024] = ""; | |
7699 | |
7700 if(!_user_dir[0]) | |
7701 { | |
7702 char *home = getenv("HOME"); | |
7703 | |
7704 if(home) | |
7705 strcpy(_user_dir, home); | |
7706 else | |
7707 strcpy(_user_dir, "/"); | |
7708 } | |
7709 return _user_dir; | |
7710 } | |
7711 | |
7712 /* | |
7713 * Call a function from the window (widget)'s context. | |
7714 * Parameters: | |
7715 * handle: Window handle of the widget. | |
7716 * function: Function pointer to be called. | |
7717 * data: Pointer to the data to be passed to the function. | |
7718 */ | |
7719 void dw_window_function(HWND handle, void *function, void *data) | |
7720 { | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
7721 void (* windowfunc)(void *); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
7722 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
7723 windowfunc = function; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
7724 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
7725 if(windowfunc) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
7726 windowfunc(data); |
3 | 7727 } |
7728 | |
90
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7729 /* |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7730 * 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:
87
diff
changeset
|
7731 * Parameters: |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7732 * 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:
87
diff
changeset
|
7733 * 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:
87
diff
changeset
|
7734 * 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:
87
diff
changeset
|
7735 */ |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7736 void dw_window_set_data(HWND window, char *dataname, void *data) |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7737 { |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7738 int _locked_by_me = FALSE; |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7739 |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7740 if(!window) |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7741 return; |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7742 |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7743 DW_MUTEX_LOCK; |
112
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
7744 if(GTK_IS_OBJECT(window)) |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
7745 { |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
7746 if(GTK_IS_SCROLLED_WINDOW(window)) |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
7747 { |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
7748 HWND thiswindow = (HWND)gtk_object_get_user_data(GTK_OBJECT(window)); |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
7749 |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
7750 if(thiswindow && GTK_IS_OBJECT(thiswindow)) |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
7751 gtk_object_set_data(GTK_OBJECT(thiswindow), dataname, (gpointer)data); |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
7752 } |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
7753 if(GTK_IS_COMBO(window)) |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
7754 gtk_object_set_data(GTK_OBJECT(GTK_COMBO(window)->entry), dataname, (gpointer)data); |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
7755 gtk_object_set_data(GTK_OBJECT(window), dataname, (gpointer)data); |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
7756 } |
90
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7757 DW_MUTEX_UNLOCK; |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7758 } |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7759 |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7760 /* |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7761 * 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:
87
diff
changeset
|
7762 * Parameters: |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
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:
87
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:
87
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:
87
diff
changeset
|
7766 */ |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7767 void *dw_window_get_data(HWND window, char *dataname) |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7768 { |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7769 int _locked_by_me = FALSE; |
112
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
7770 void *ret = NULL; |
90
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7771 |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7772 if(!window) |
92
0a085f295e81
A couple more minor changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
91
diff
changeset
|
7773 return NULL; |
90
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7774 |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7775 DW_MUTEX_LOCK; |
112
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
7776 if(GTK_IS_OBJECT(window)) |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
7777 ret = (void *)gtk_object_get_data(GTK_OBJECT(window), dataname); |
90
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7778 DW_MUTEX_UNLOCK; |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7779 return ret; |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7780 } |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7781 |
3 | 7782 /* |
195
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7783 * Add a callback to a timer event. |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7784 * Parameters: |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7785 * interval: Milliseconds to delay between calls. |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7786 * sigfunc: The pointer to the function to be used as the callback. |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7787 * data: User data to be passed to the handler function. |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7788 * Returns: |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7789 * Timer ID for use with dw_timer_disconnect(), 0 on error. |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7790 */ |
199
b955228477b3
Removed the window parameter to dw_timer_connect() it was no needed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
198
diff
changeset
|
7791 int API dw_timer_connect(int interval, void *sigfunc, void *data) |
195
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7792 { |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7793 int tag, _locked_by_me = FALSE; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7794 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7795 DW_MUTEX_LOCK; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7796 tag = gtk_timeout_add(interval, (GtkFunction)sigfunc, data); |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7797 DW_MUTEX_UNLOCK; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7798 return tag; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7799 } |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7800 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7801 /* |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7802 * Removes timer callback. |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7803 * Parameters: |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7804 * id: Timer ID returned by dw_timer_connect(). |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7805 */ |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7806 void API dw_timer_disconnect(int id) |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7807 { |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7808 int _locked_by_me = FALSE; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7809 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7810 DW_MUTEX_LOCK; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7811 gtk_timeout_remove(id); |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7812 DW_MUTEX_UNLOCK; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7813 } |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7814 |
410
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
7815 /* Get the actual signal window handle not the user window handle |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
7816 * Should mimic the code in dw_signal_connect() below. |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
7817 */ |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
7818 static HWND _find_signal_window(HWND window, char *signame) |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
7819 { |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
7820 HWND thiswindow = window; |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
7821 |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
7822 if(GTK_IS_SCROLLED_WINDOW(thiswindow)) |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
7823 thiswindow = (HWND)gtk_object_get_user_data(GTK_OBJECT(window)); |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
7824 else if(GTK_IS_COMBO(thiswindow) && signame && strcmp(signame, DW_SIGNAL_LIST_SELECT) == 0) |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
7825 thiswindow = GTK_COMBO(thiswindow)->list; |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
7826 else if(GTK_IS_COMBO(thiswindow) && signame && strcmp(signame, DW_SIGNAL_SET_FOCUS) == 0) |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
7827 thiswindow = GTK_COMBO(thiswindow)->entry; |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
7828 else if(GTK_IS_VSCALE(thiswindow) || GTK_IS_HSCALE(thiswindow) || |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
7829 GTK_IS_VSCROLLBAR(thiswindow) || GTK_IS_HSCROLLBAR(thiswindow)) |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
7830 thiswindow = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(thiswindow), "_dw_adjustment"); |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
7831 #if GTK_MAJOR_VERSION > 1 |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
7832 else if(GTK_IS_TREE_VIEW(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_SELECT) == 0) |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
7833 thiswindow = (GtkWidget *)gtk_tree_view_get_selection(GTK_TREE_VIEW(thiswindow)); |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
7834 #endif |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
7835 return thiswindow; |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
7836 } |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
7837 |
195
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7838 /* |
3 | 7839 * Add a callback to a window event. |
7840 * Parameters: | |
7841 * window: Window handle of signal to be called back. | |
7842 * signame: A string pointer identifying which signal to be hooked. | |
7843 * sigfunc: The pointer to the function to be used as the callback. | |
7844 * data: User data to be passed to the handler function. | |
7845 */ | |
7846 void dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data) | |
7847 { | |
7848 void *thisfunc = _findsigfunc(signame); | |
7849 char *thisname = signame; | |
7850 HWND thiswindow = window; | |
409
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
7851 int sigid, _locked_by_me = FALSE; |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
7852 gint cid; |
3 | 7853 |
7854 DW_MUTEX_LOCK; | |
7855 if(GTK_IS_SCROLLED_WINDOW(thiswindow)) | |
7856 { | |
7857 thiswindow = (HWND)gtk_object_get_user_data(GTK_OBJECT(window)); | |
7858 } | |
7859 | |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7860 if(GTK_IS_MENU_ITEM(thiswindow) && strcmp(signame, DW_SIGNAL_CLICKED) == 0) |
3 | 7861 { |
7862 thisname = "activate"; | |
7863 thisfunc = _findsigfunc(thisname); | |
7864 } | |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7865 else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_CONTEXT) == 0) |
3 | 7866 { |
7867 thisname = "button_press_event"; | |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7868 thisfunc = _findsigfunc(DW_SIGNAL_ITEM_CONTEXT); |
3 | 7869 } |
140
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
7870 #if GTK_MAJOR_VERSION > 1 |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7871 else if(GTK_IS_TREE_VIEW(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_CONTEXT) == 0) |
140
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
7872 { |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
7873 thisfunc = _findsigfunc("tree-context"); |
409
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
7874 sigid = _set_signal_handler(thiswindow, window, sigfunc, data, thisfunc); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
7875 cid = gtk_signal_connect(GTK_OBJECT(thiswindow), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), (gpointer)sigid); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
7876 _set_signal_handler_id(thiswindow, sigid, cid); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
7877 sigid = _set_signal_handler(window, window, sigfunc, data, thisfunc); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
7878 cid = gtk_signal_connect(GTK_OBJECT(window), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), (gpointer)sigid); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
7879 _set_signal_handler_id(window, sigid, cid); |
140
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
7880 DW_MUTEX_UNLOCK; |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
7881 return; |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
7882 } |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7883 else if(GTK_IS_TREE_VIEW(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_SELECT) == 0) |
140
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
7884 { |
362
eb61b854fd58
Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
361
diff
changeset
|
7885 GtkWidget *treeview = thiswindow; |
eb61b854fd58
Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
361
diff
changeset
|
7886 |
140
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
7887 thiswindow = (GtkWidget *)gtk_tree_view_get_selection(GTK_TREE_VIEW(thiswindow)); |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
7888 thisname = "changed"; |
409
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
7889 |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
7890 sigid = _set_signal_handler(treeview, window, sigfunc, data, thisfunc); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
7891 cid = g_signal_connect(G_OBJECT(thiswindow), thisname, (GCallback)thisfunc, (gpointer)sigid); |
422
3269c10bc243
Using GtkTreeSelection instead of GtkTreeView in the signal handler code
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
420
diff
changeset
|
7892 _set_signal_handler_id(treeview, sigid, cid); |
140
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
7893 DW_MUTEX_UNLOCK; |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
7894 return; |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
7895 } |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
7896 #else |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7897 else if(GTK_IS_TREE(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_CONTEXT) == 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
|
7898 { |
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
|
7899 thisfunc = _findsigfunc("tree-context"); |
409
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
7900 sigid = _set_signal_handler(thiswindow, window, sigfunc, data, thisfunc); |
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
|
7901 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7902 gtk_object_set_data(GTK_OBJECT(thiswindow), "_dw_container_context_func", (gpointer)thisfunc); |
409
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
7903 gtk_object_set_data(GTK_OBJECT(thiswindow), "_dw_container_context_data", (gpointer)sigid); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
7904 cid = gtk_signal_connect(GTK_OBJECT(thiswindow), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), (gpointer)sigid); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
7905 _set_signal_handler_id(thiswindow, sigid, cid); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
7906 sigid = _set_signal_handler(window, window, sigfunc, data, thisfunc); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
7907 cid = gtk_signal_connect(GTK_OBJECT(window), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), (gpointer)sigid); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
7908 _set_signal_handler_id(window, sigid, cid); |
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
|
7909 DW_MUTEX_UNLOCK; |
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
|
7910 return; |
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
|
7911 } |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7912 else if(GTK_IS_TREE(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_SELECT) == 0) |
140
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
7913 { |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
7914 if(thisfunc) |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
7915 { |
409
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
7916 sigid = _set_signal_handler(thiswindow, window, sigfunc, data, thisfunc); |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7917 gtk_object_set_data(GTK_OBJECT(thiswindow), "_dw_select_child_func", (gpointer)thisfunc); |
409
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
7918 gtk_object_set_data(GTK_OBJECT(thiswindow), "_dw_select_child_data", (gpointer)sigid); |
140
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
7919 } |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
7920 thisname = "select-child"; |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
7921 } |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
7922 #endif |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7923 else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_ENTER) == 0) |
3 | 7924 { |
409
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
7925 sigid = _set_signal_handler(thiswindow, window, sigfunc, data, _container_enter_event); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
7926 cid = gtk_signal_connect(GTK_OBJECT(thiswindow), "key_press_event", GTK_SIGNAL_FUNC(_container_enter_event), (gpointer)sigid); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
7927 _set_signal_handler_id(thiswindow, sigid, cid); |
364
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
7928 |
3 | 7929 thisname = "button_press_event"; |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7930 thisfunc = _findsigfunc(DW_SIGNAL_ITEM_ENTER); |
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7931 } |
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7932 else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_SELECT) == 0) |
164
d35771f70bdd
Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
163
diff
changeset
|
7933 { |
d35771f70bdd
Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
163
diff
changeset
|
7934 thisname = "select_row"; |
d35771f70bdd
Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
163
diff
changeset
|
7935 thisfunc = (void *)_container_select_row; |
d35771f70bdd
Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
163
diff
changeset
|
7936 } |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7937 else if(GTK_IS_COMBO(thiswindow) && strcmp(signame, DW_SIGNAL_LIST_SELECT) == 0) |
3 | 7938 { |
7939 thisname = "select_child"; | |
7940 thiswindow = GTK_COMBO(thiswindow)->list; | |
7941 } | |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7942 else if(GTK_IS_LIST(thiswindow) && strcmp(signame, DW_SIGNAL_LIST_SELECT) == 0) |
3 | 7943 { |
7944 thisname = "select_child"; | |
7945 } | |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7946 else if(strcmp(signame, DW_SIGNAL_SET_FOCUS) == 0) |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
7947 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
7948 thisname = "focus-in-event"; |
39
3aa9ef0b3996
Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
37
diff
changeset
|
7949 if(GTK_IS_COMBO(thiswindow)) |
3aa9ef0b3996
Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
37
diff
changeset
|
7950 thiswindow = GTK_COMBO(thiswindow)->entry; |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
7951 } |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7952 #if 0 |
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7953 else if(strcmp(signame, DW_SIGNAL_LOSE_FOCUS) == 0) |
55
b6948eac375a
Sync with the latest dynamic windows, tree fixes, and other miscellaneous
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
54
diff
changeset
|
7954 { |
b6948eac375a
Sync with the latest dynamic windows, tree fixes, and other miscellaneous
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
54
diff
changeset
|
7955 thisname = "focus-out-event"; |
b6948eac375a
Sync with the latest dynamic windows, tree fixes, and other miscellaneous
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
54
diff
changeset
|
7956 if(GTK_IS_COMBO(thiswindow)) |
b6948eac375a
Sync with the latest dynamic windows, tree fixes, and other miscellaneous
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
54
diff
changeset
|
7957 thiswindow = GTK_COMBO(thiswindow)->entry; |
b6948eac375a
Sync with the latest dynamic windows, tree fixes, and other miscellaneous
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
54
diff
changeset
|
7958 } |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7959 #endif |
205
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
7960 else if(GTK_IS_VSCALE(thiswindow) || GTK_IS_HSCALE(thiswindow) || |
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
7961 GTK_IS_VSCROLLBAR(thiswindow) || GTK_IS_HSCROLLBAR(thiswindow)) |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
7962 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7963 thiswindow = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(thiswindow), "_dw_adjustment"); |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
7964 } |
331
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
7965 else if(GTK_IS_NOTEBOOK(thiswindow) && strcmp(signame, DW_SIGNAL_SWITCH_PAGE) == 0) |
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
7966 { |
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
7967 thisname = "switch-page"; |
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
7968 } |
3 | 7969 |
7970 if(!thisfunc || !thiswindow) | |
7971 { | |
7972 DW_MUTEX_UNLOCK; | |
7973 return; | |
7974 } | |
7975 | |
409
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
7976 sigid = _set_signal_handler(thiswindow, window, sigfunc, data, thisfunc); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
7977 cid = gtk_signal_connect(GTK_OBJECT(thiswindow), thisname, GTK_SIGNAL_FUNC(thisfunc),(gpointer)sigid); |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
7978 _set_signal_handler_id(thiswindow, sigid, cid); |
3 | 7979 DW_MUTEX_UNLOCK; |
7980 } | |
7981 | |
7982 /* | |
7983 * Removes callbacks for a given window with given name. | |
7984 * Parameters: | |
7985 * window: Window handle of callback to be removed. | |
7986 */ | |
7987 void dw_signal_disconnect_by_name(HWND window, char *signame) | |
7988 { | |
410
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
7989 HWND thiswindow; |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
7990 int z, count; |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
7991 void *thisfunc; |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
7992 int _locked_by_me = FALSE; |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
7993 |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
7994 DW_MUTEX_LOCK; |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
7995 thiswindow = _find_signal_window(window, signame); |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
7996 count = (int)gtk_object_get_data(GTK_OBJECT(thiswindow), "_dw_sigcounter"); |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
7997 thisfunc = _findsigfunc(signame); |
409
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
7998 |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
7999 for(z=0;z<count;z++) |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
8000 { |
410
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
8001 SignalHandler sh = _get_signal_handler(thiswindow, (gpointer)z); |
409
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
8002 |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
8003 if(sh.intfunc == thisfunc) |
410
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
8004 _remove_signal_handler(thiswindow, z); |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
8005 } |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
8006 DW_MUTEX_UNLOCK; |
3 | 8007 } |
8008 | |
8009 /* | |
8010 * Removes all callbacks for a given window. | |
8011 * Parameters: | |
8012 * window: Window handle of callback to be removed. | |
8013 */ | |
8014 void dw_signal_disconnect_by_window(HWND window) | |
8015 { | |
410
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
8016 HWND thiswindow; |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
8017 int z, count; |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
8018 int _locked_by_me = FALSE; |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
8019 |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
8020 DW_MUTEX_LOCK; |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
8021 thiswindow = _find_signal_window(window, NULL); |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
8022 count = (int)gtk_object_get_data(GTK_OBJECT(thiswindow), "_dw_sigcounter"); |
409
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
8023 |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
8024 for(z=0;z<count;z++) |
410
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
8025 _remove_signal_handler(thiswindow, z); |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
8026 gtk_object_set_data(GTK_OBJECT(thiswindow), "_dw_sigcounter", NULL); |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
8027 DW_MUTEX_UNLOCK; |
3 | 8028 } |
8029 | |
8030 /* | |
8031 * Removes all callbacks for a given window with specified data. | |
8032 * Parameters: | |
8033 * window: Window handle of callback to be removed. | |
8034 * data: Pointer to the data to be compared against. | |
8035 */ | |
8036 void dw_signal_disconnect_by_data(HWND window, void *data) | |
8037 { | |
410
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
8038 HWND thiswindow; |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
8039 int z, count; |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
8040 int _locked_by_me = FALSE; |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
8041 |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
8042 DW_MUTEX_LOCK; |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
8043 thiswindow = _find_signal_window(window, NULL); |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
8044 count = (int)gtk_object_get_data(GTK_OBJECT(thiswindow), "_dw_sigcounter"); |
409
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
8045 |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
8046 for(z=0;z<count;z++) |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
8047 { |
410
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
8048 SignalHandler sh = _get_signal_handler(thiswindow, (gpointer)z); |
409
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
8049 |
1d7be77cbfb5
Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
407
diff
changeset
|
8050 if(sh.data == data) |
410
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
8051 _remove_signal_handler(thiswindow, z); |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
8052 } |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
8053 DW_MUTEX_UNLOCK; |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
8054 } |
47273b6a8500
Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
409
diff
changeset
|
8055 |