Mercurial > dwindows
annotate gtk/dw.c @ 403:6a3ef130962f
Check that the child is actually a label before trying to operate on it.
Will avoid warnings on bitmap buttons.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sat, 10 May 2003 07:54:09 +0000 |
parents | 0f0183aa2b05 |
children | a8124a9561c7 |
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; | |
131 | |
132 } SignalHandler; | |
133 | |
331
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
134 #define SIGNALMAX 17 |
3 | 135 |
136 /* 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
|
137 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
|
138 { _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
|
139 { _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
|
140 { _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
|
141 { _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
|
142 { _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
|
143 { _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
|
144 { _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
|
145 { _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
|
146 { _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
|
147 { _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
|
148 { _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
|
149 { _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
|
150 { _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
|
151 { _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
|
152 { _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
|
153 { _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
|
154 { _switch_page_event, DW_SIGNAL_SWITCH_PAGE } |
3 | 155 }; |
156 | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
157 /* Alignment flags */ |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
158 #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
|
159 #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
|
160 #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
|
161 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
162 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
|
163 { |
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
164 #ifdef __sun__ |
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
165 /* 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
|
166 struct timespec req; |
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
167 |
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
168 req.tv_sec = 0; |
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
169 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
|
170 |
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
171 nanosleep(&req, NULL); |
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
172 #else |
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
173 usleep(period * 1000); |
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
174 #endif |
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
175 } |
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
176 |
3 | 177 /* 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
|
178 static void *_findsigfunc(char *signame) |
3 | 179 { |
180 int z; | |
181 | |
182 for(z=0;z<SIGNALMAX;z++) | |
183 { | |
184 if(strcasecmp(signame, SignalTranslate[z].name) == 0) | |
185 return SignalTranslate[z].func; | |
186 } | |
187 return NULL; | |
188 } | |
189 | |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
190 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
|
191 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
192 int counter = (int)data; |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
193 SignalHandler sh; |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
194 char text[100]; |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
195 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
196 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
|
197 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
|
198 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
|
199 sh.func = (void *)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_sigdata%d", counter); |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
201 sh.data = 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
|
202 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
203 return sh; |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
204 } |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
205 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
206 static int _set_signal_handler(GtkWidget *widget, HWND window, void *func, gpointer data) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
207 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
208 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
|
209 char text[100]; |
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 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
|
212 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
|
213 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
|
214 gtk_object_set_data(GTK_OBJECT(widget), text, (gpointer)func); |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
215 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
|
216 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
|
217 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
218 counter++; |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
219 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
|
220 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
221 return counter - 1; |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
222 } |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
223 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
224 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
|
225 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
226 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
|
227 int retval = FALSE; |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
228 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
229 if(work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
230 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
231 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
|
232 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
233 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
|
234 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
235 return retval; |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
236 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
237 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
238 static gint _button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data) |
3 | 239 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
240 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
|
241 int retval = FALSE; |
3 | 242 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
243 if(work.window) |
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 int (*buttonfunc)(HWND, int, int, int, void *) = work.func; |
3 | 246 int mybutton = event->button; |
247 | |
248 if(event->button == 3) | |
249 mybutton = 2; | |
250 else if(event->button == 2) | |
251 mybutton = 3; | |
252 | |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
253 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
|
254 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
255 return retval; |
3 | 256 } |
257 | |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
258 static gint _button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer data) |
3 | 259 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
260 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
|
261 int retval = FALSE; |
3 | 262 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
263 if(work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
264 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
265 int (*buttonfunc)(HWND, int, int, int, void *) = work.func; |
3 | 266 int mybutton = event->button; |
267 | |
268 if(event->button == 3) | |
269 mybutton = 2; | |
270 else if(event->button == 2) | |
271 mybutton = 3; | |
272 | |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
273 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
|
274 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
275 return retval; |
3 | 276 } |
277 | |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
278 static gint _motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gpointer data) |
3 | 279 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
280 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
|
281 int retval = FALSE; |
3 | 282 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
283 if(work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
284 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
285 int (*motionfunc)(HWND, int, int, int, void *) = work.func; |
3 | 286 int keys = 0, x, y; |
287 GdkModifierType state; | |
288 | |
289 if (event->is_hint) | |
290 gdk_window_get_pointer (event->window, &x, &y, &state); | |
291 else | |
292 { | |
293 x = event->x; | |
294 y = event->y; | |
295 state = event->state; | |
296 } | |
297 | |
298 if (state & GDK_BUTTON1_MASK) | |
299 keys = DW_BUTTON1_MASK; | |
300 if (state & GDK_BUTTON3_MASK) | |
301 keys |= DW_BUTTON2_MASK; | |
302 if (state & GDK_BUTTON2_MASK) | |
303 keys |= DW_BUTTON3_MASK; | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
304 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
305 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
|
306 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
307 return retval; |
3 | 308 } |
309 | |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
310 static gint _delete_event(GtkWidget *widget, GdkEvent *event, gpointer data) |
3 | 311 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
312 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
|
313 int retval = FALSE; |
3 | 314 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
315 if(work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
316 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
317 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
|
318 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
319 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
|
320 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
321 return retval; |
3 | 322 } |
323 | |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
324 static gint _key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data) |
3 | 325 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
326 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
|
327 int retval = FALSE; |
3 | 328 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
329 if(work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
330 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
331 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
|
332 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
333 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
|
334 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
|
335 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
336 return retval; |
3 | 337 } |
338 | |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
339 static gint _generic_event(GtkWidget *widget, gpointer data) |
3 | 340 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
341 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
|
342 int retval = FALSE; |
3 | 343 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
344 if(work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
345 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
346 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
|
347 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
348 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
|
349 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
350 return retval; |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
351 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
352 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
353 static gint _activate_event(GtkWidget *widget, gpointer data) |
3 | 354 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
355 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
|
356 int retval = FALSE; |
3 | 357 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
358 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
|
359 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
360 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
|
361 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
362 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
|
363 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
364 return retval; |
3 | 365 } |
366 | |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
367 static gint _configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data) |
3 | 368 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
369 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
|
370 int retval = FALSE; |
3 | 371 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
372 if(work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
373 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
374 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
|
375 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
376 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
|
377 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
378 return retval; |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
379 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
380 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
381 static gint _expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data) |
3 | 382 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
383 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
|
384 int retval = FALSE; |
3 | 385 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
386 if(work.window) |
3 | 387 { |
388 DWExpose exp; | |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
389 int (*exposefunc)(HWND, DWExpose *, void *) = work.func; |
3 | 390 |
391 exp.x = event->area.x; | |
392 exp.y = event->area.y; | |
393 exp.width = event->area.width; | |
394 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
|
395 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
|
396 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
397 return retval; |
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 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
400 static gint _item_select_event(GtkWidget *widget, GtkWidget *child, gpointer data) |
3 | 401 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
402 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
|
403 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
|
404 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
|
405 |
3aa9ef0b3996
Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
37
diff
changeset
|
406 if(_dw_recursing) |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
407 return FALSE; |
3 | 408 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
409 if(work.window) |
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 int (*selectfunc)(HWND, int, void *) = work.func; |
3 | 412 GList *list; |
413 int item = 0; | |
414 | |
39
3aa9ef0b3996
Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
37
diff
changeset
|
415 _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
|
416 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
417 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
|
418 list = GTK_LIST(GTK_COMBO(work.window)->list)->children; |
3 | 419 else if(GTK_IS_LIST(widget)) |
420 list = GTK_LIST(widget)->children; | |
421 else | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
422 return FALSE; |
3 | 423 |
424 while(list) | |
425 { | |
426 if(list->data == (gpointer)child) | |
427 { | |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
428 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
|
429 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
430 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
|
431 if(selectfunc) |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
432 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
|
433 } |
3 | 434 break; |
435 } | |
436 item++; | |
437 list = list->next; | |
438 } | |
39
3aa9ef0b3996
Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
37
diff
changeset
|
439 _dw_recursing = 0; |
3 | 440 } |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
441 return retval; |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
442 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
443 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
444 static gint _container_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data) |
3 | 445 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
446 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
|
447 int retval = FALSE; |
3 | 448 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
449 if(work.window) |
3 | 450 { |
451 if(event->button == 3) | |
452 { | |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
453 int (*contextfunc)(HWND, char *, int, int, void *, void *) = work.func; |
3 | 454 char *text; |
455 int row, col; | |
456 | |
457 gtk_clist_get_selection_info(GTK_CLIST(widget), event->x, event->y, &row, &col); | |
458 | |
459 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
|
460 retval = contextfunc(work.window, text, event->x, event->y, work.data, NULL); |
3 | 461 } |
462 } | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
463 return retval; |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
464 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
465 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
466 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
|
467 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
468 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
|
469 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
|
470 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
471 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
|
472 { |
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
|
473 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
|
474 { |
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
|
475 #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
|
476 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
|
477 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
|
478 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
|
479 |
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
|
480 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
|
481 { |
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
|
482 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
|
483 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
|
484 |
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
|
485 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
|
486 { |
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
|
487 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
|
488 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
|
489 } |
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
|
490 } |
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
|
491 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
492 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
|
493 #else |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
494 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
|
495 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
|
496 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
|
497 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
498 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
|
499 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
500 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
|
501 |
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 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
|
503 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
504 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
|
505 |
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
|
506 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
|
507 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
508 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
|
509 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
|
510 } |
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
|
511 } |
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
|
512 } |
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
|
513 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
514 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
|
515 #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
|
516 } |
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
|
517 } |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
518 return retval; |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
519 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
520 |
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
|
521 #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
|
522 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
|
523 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
524 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
|
525 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
|
526 |
362
eb61b854fd58
Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
361
diff
changeset
|
527 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
|
528 { |
eb61b854fd58
Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
361
diff
changeset
|
529 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
|
530 |
eb61b854fd58
Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
361
diff
changeset
|
531 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
|
532 { |
362
eb61b854fd58
Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
361
diff
changeset
|
533 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
|
534 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
|
535 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
|
536 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
|
537 |
eb61b854fd58
Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
361
diff
changeset
|
538 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
|
539 { |
eb61b854fd58
Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
361
diff
changeset
|
540 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
|
541 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
|
542 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
|
543 } |
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
|
544 } |
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
|
545 } |
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
|
546 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
|
547 } |
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
|
548 #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
|
549 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
|
550 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
551 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
|
552 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
|
553 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
|
554 |
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
|
555 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
|
556 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
557 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
|
558 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
|
559 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
|
560 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
|
561 } |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
562 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
563 if(work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
564 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
565 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
|
566 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
|
567 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
|
568 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
|
569 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
570 return retval; |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
571 } |
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
|
572 #endif |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
573 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
574 static gint _container_select_event(GtkWidget *widget, GdkEventButton *event, gpointer data) |
3 | 575 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
576 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
|
577 int retval = FALSE; |
3 | 578 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
579 if(work.window) |
3 | 580 { |
581 if(event->button == 1 && event->type == GDK_2BUTTON_PRESS) | |
582 { | |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
583 int (*contextfunc)(HWND, char *, void *) = work.func; |
3 | 584 char *text; |
585 int row, col; | |
586 | |
587 gtk_clist_get_selection_info(GTK_CLIST(widget), event->x, event->y, &row, &col); | |
588 | |
589 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
|
590 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
|
591 gtk_object_set_data(GTK_OBJECT(widget), "_dw_double_click", (gpointer)1); |
3 | 592 } |
593 } | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
594 return retval; |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
595 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
596 |
364
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
597 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
|
598 { |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
599 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
|
600 int retval = FALSE; |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
601 |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
602 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
|
603 { |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
604 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
|
605 char *text; |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
606 |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
607 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
|
608 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
|
609 } |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
610 return retval; |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
611 } |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
612 |
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
|
613 /* 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
|
614 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
|
615 { |
599644ca9064
Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
340
diff
changeset
|
616 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
|
617 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
|
618 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
|
619 |
599644ca9064
Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
340
diff
changeset
|
620 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
|
621 { |
599644ca9064
Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
340
diff
changeset
|
622 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
|
623 { |
599644ca9064
Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
340
diff
changeset
|
624 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
|
625 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
|
626 } |
599644ca9064
Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
340
diff
changeset
|
627 } |
599644ca9064
Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
340
diff
changeset
|
628 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
|
629 } |
599644ca9064
Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
340
diff
changeset
|
630 |
599644ca9064
Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
340
diff
changeset
|
631 |
331
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
632 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
|
633 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
634 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
|
635 int retval = FALSE; |
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
636 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
637 if(work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
638 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
639 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
|
640 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
|
641 } |
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
642 return retval; |
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
643 } |
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
644 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
645 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
|
646 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
647 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
|
648 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
|
649 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
|
650 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
651 if(!work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
652 return TRUE; |
311
24c1dfffe97e
Unified the callback functions for tree and container widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
310
diff
changeset
|
653 |
320
ae5b1eecea12
Don't send a DW_SIGNAL_ITEM_SELECT after DW_SIGNAL_ENTER.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
319
diff
changeset
|
654 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
|
655 { |
ae5b1eecea12
Don't send a DW_SIGNAL_ITEM_SELECT after DW_SIGNAL_ENTER.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
319
diff
changeset
|
656 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
|
657 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
|
658 } |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
659 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
|
660 } |
d35771f70bdd
Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
163
diff
changeset
|
661 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
662 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
|
663 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
664 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
|
665 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
666 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
|
667 newval++; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
668 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
669 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
|
670 } |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
671 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
672 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
|
673 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
674 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
|
675 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
|
676 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
|
677 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
|
678 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
679 if(slider) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
680 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
681 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
|
682 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
683 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
|
684 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
685 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
|
686 |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
687 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
|
688 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
|
689 else |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
690 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
|
691 } |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
692 } |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
693 else if(scrollbar) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
694 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
695 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
|
696 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
697 if(work.window) |
208
5349a0735fda
Hopefully fixed value_changed signal handler on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
205
diff
changeset
|
698 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
699 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
|
700 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
701 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
|
702 } |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
703 } |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
704 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
|
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 _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
|
708 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
709 GtkWidget *next = (GtkWidget *)data; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
710 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
711 if(next) |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
712 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
713 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
|
714 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
715 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
|
716 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
|
717 else |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
718 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
|
719 } |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
720 } |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
721 return FALSE; |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
722 } |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
723 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
724 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
|
725 { |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
726 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
|
727 { |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
728 *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
|
729 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
|
730 *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
|
731 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
|
732 *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
|
733 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
|
734 } |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
735 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
|
736 } |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
737 |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
738 static GdkPixmap *_find_pixmap(GdkBitmap **bitmap, long id, HWND handle, unsigned long *userwidth, unsigned long *userheight) |
3 | 739 { |
740 char *data = NULL; | |
741 int z; | |
742 | |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
743 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
|
744 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
|
745 |
3 | 746 for(z=0;z<_resources.resource_max;z++) |
747 { | |
748 if(_resources.resource_id[z] == id) | |
749 { | |
750 data = _resources.resource_data[z]; | |
751 break; | |
752 } | |
753 } | |
754 | |
755 if(data) | |
756 { | |
757 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
|
758 #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
|
759 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
|
760 |
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
761 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
|
762 *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
|
763 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
|
764 *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
|
765 |
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
766 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
|
767 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
|
768 #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
|
769 gdk_imlib_data_to_pixmap((char **)data, &icon_pixmap, bitmap); |
3 | 770 #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
|
771 icon_pixmap = gdk_pixmap_create_from_xpm_d(handle->window, bitmap, &_colors[DW_CLR_PALEGRAY], (char **)data); |
3 | 772 #endif |
773 return icon_pixmap; | |
774 } | |
775 return NULL; | |
776 } | |
777 | |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
778 #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
|
779 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
|
780 { |
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
|
781 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
|
782 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
|
783 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
|
784 } |
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
|
785 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
786 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
|
787 { |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
788 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
|
789 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
|
790 |
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
|
791 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
|
792 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
|
793 |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
794 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
|
795 { |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
796 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
|
797 { |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
798 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
|
799 break; |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
800 } |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
801 } |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
802 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
803 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
|
804 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
|
805 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
|
806 } |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
807 #endif |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
808 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
809 static void _size_allocate(GtkWindow *window) |
3 | 810 { |
811 XSizeHints sizehints; | |
812 | |
813 sizehints.base_width = 1; | |
814 sizehints.base_height = 1; | |
815 sizehints.width_inc = 1; | |
816 sizehints.height_inc = 1; | |
817 sizehints.min_width = 8; | |
818 sizehints.min_height = 8; | |
819 | |
820 sizehints.flags = (PBaseSize|PMinSize|PResizeInc); | |
821 | |
822 XSetWMNormalHints (GDK_DISPLAY(), | |
823 GDK_WINDOW_XWINDOW (GTK_WIDGET (window)->window), | |
824 &sizehints); | |
825 gdk_flush (); | |
826 } | |
827 | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
828 /* 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
|
829 static int _find_thread_index(DWTID tid) |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
830 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
831 int z; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
832 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
833 for(z=0;z<DW_THREAD_LIMIT;z++) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
834 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
835 if(_dw_thread_list[z] == tid) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
836 return z; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
837 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
838 return 0; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
839 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
840 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
841 /* 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
|
842 static void _dw_thread_add(DWTID tid) |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
843 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
844 int z; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
845 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
846 for(z=0;z<DW_THREAD_LIMIT;z++) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
847 { |
264
20becf7df38a
Prevent duplicate thread IDs from getting added to the thread list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
259
diff
changeset
|
848 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
|
849 return; |
20becf7df38a
Prevent duplicate thread IDs from getting added to the thread list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
259
diff
changeset
|
850 |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
851 if(_dw_thread_list[z] == (DWTID)-1) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
852 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
853 _dw_thread_list[z] = tid; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
854 _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
|
855 _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
|
856 _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
|
857 _transparent[z] = 1; |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
858 return; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
859 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
860 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
861 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
862 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
863 /* 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
|
864 static void _dw_thread_remove(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] == (DWTID)tid) |
51
d97de82f0b6e
Fix warning on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
49
diff
changeset
|
871 _dw_thread_list[z] = (DWTID)-1; |
48
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 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
874 |
3 | 875 /* |
876 * Initializes the Dynamic Windows engine. | |
877 * Parameters: | |
878 * newthread: True if this is the only thread. | |
879 * False if there is already a message loop running. | |
880 */ | |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
881 int dw_int_init(DWResources *res, int newthread, int *argc, char **argv[]) |
3 | 882 { |
883 int z; | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
884 char *tmp; |
3 | 885 |
886 if(res) | |
887 { | |
888 _resources.resource_max = res->resource_max; | |
889 _resources.resource_id = res->resource_id; | |
890 _resources.resource_data = res->resource_data; | |
891 } | |
892 gtk_set_locale(); | |
893 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
|
894 #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
|
895 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
|
896 #endif |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
897 |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
898 gtk_init(argc, argv); |
3 | 899 #ifdef USE_IMLIB |
900 gdk_imlib_init(); | |
901 #endif | |
902 /* Add colors to the system colormap */ | |
903 _dw_cmap = gdk_colormap_get_system(); | |
904 for(z=0;z<16;z++) | |
905 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
|
906 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
907 tmp = getenv("DW_BORDER_WIDTH"); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
908 if(tmp) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
909 _dw_border_width = atoi(tmp); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
910 tmp = getenv("DW_BORDER_HEIGHT"); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
911 if(tmp) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
912 _dw_border_height = atoi(tmp); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
913 |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
914 for(z=0;z<DW_THREAD_LIMIT;z++) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
915 _dw_thread_list[z] = (DWTID)-1; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
916 |
77
002da4d18ac6
Set tooltip background color to yellow.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
76
diff
changeset
|
917 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
|
918 |
3 | 919 return TRUE; |
920 } | |
921 | |
922 /* | |
923 * 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
|
924 */ |
2a0d7b57a6da
Removed unnecessary parameters from dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
149
diff
changeset
|
925 void dw_main(void) |
3 | 926 { |
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
|
927 gdk_threads_enter(); |
3 | 928 _dw_thread = pthread_self(); |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
929 _dw_thread_add(_dw_thread); |
3 | 930 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
|
931 _dw_thread = (pthread_t)-1; |
3 | 932 gdk_threads_leave(); |
933 } | |
934 | |
935 /* | |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
936 * 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
|
937 * 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
|
938 * 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
|
939 */ |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
940 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
|
941 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
942 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
|
943 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
|
944 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
945 gettimeofday(&start, NULL); |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
946 |
340
eff674cb4935
Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
338
diff
changeset
|
947 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
|
948 { |
eff674cb4935
Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
338
diff
changeset
|
949 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
|
950 |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
951 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
|
952 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
953 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
|
954 { |
340
eff674cb4935
Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
338
diff
changeset
|
955 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
|
956 { |
eff674cb4935
Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
338
diff
changeset
|
957 gdk_threads_enter(); |
eff674cb4935
Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
338
diff
changeset
|
958 _dw_thread = curr; |
eff674cb4935
Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
338
diff
changeset
|
959 } |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
960 if(gtk_events_pending()) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
961 gtk_main_iteration(); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
962 else |
237
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
963 _dw_msleep(1); |
340
eff674cb4935
Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
338
diff
changeset
|
964 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
|
965 { |
eff674cb4935
Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
338
diff
changeset
|
966 _dw_thread = orig; |
eff674cb4935
Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
338
diff
changeset
|
967 gdk_threads_leave(); |
eff674cb4935
Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
338
diff
changeset
|
968 } |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
969 gettimeofday(&tv, NULL); |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
970 } |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
971 } |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
972 else |
237
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
973 _dw_msleep(milliseconds); |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
974 } |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
975 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
976 /* |
205
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
977 * 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
|
978 */ |
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
979 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
|
980 { |
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
|
981 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
|
982 _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
|
983 _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
|
984 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
|
985 _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
|
986 gdk_threads_leave(); |
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
987 } |
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
988 |
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
989 /* |
3 | 990 * Free's memory allocated by dynamic windows. |
991 * Parameters: | |
992 * ptr: Pointer to dynamic windows allocated | |
993 * memory to be free()'d. | |
994 */ | |
995 void dw_free(void *ptr) | |
996 { | |
997 free(ptr); | |
998 } | |
999 | |
1000 /* | |
1001 * Allocates and initializes a dialog struct. | |
1002 * Parameters: | |
1003 * data: User defined data to be passed to functions. | |
1004 */ | |
1005 DWDialog *dw_dialog_new(void *data) | |
1006 { | |
1007 DWDialog *tmp = malloc(sizeof(DWDialog)); | |
1008 | |
1009 tmp->eve = dw_event_new(); | |
1010 dw_event_reset(tmp->eve); | |
1011 tmp->data = data; | |
1012 tmp->done = FALSE; | |
1013 tmp->result = NULL; | |
1014 | |
1015 return tmp; | |
1016 } | |
1017 | |
1018 /* | |
1019 * Accepts a dialog struct and returns the given data to the | |
1020 * initial called of dw_dialog_wait(). | |
1021 * Parameters: | |
1022 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). | |
1023 * result: Data to be returned by dw_dialog_wait(). | |
1024 */ | |
1025 int dw_dialog_dismiss(DWDialog *dialog, void *result) | |
1026 { | |
1027 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
|
1028 if(pthread_self() == _dw_thread || _dw_thread == (pthread_t)-1) |
3 | 1029 gtk_main_quit(); |
1030 else | |
1031 dw_event_post(dialog->eve); | |
1032 dialog->done = TRUE; | |
1033 return 0; | |
1034 } | |
1035 | |
1036 /* | |
1037 * Accepts a dialog struct waits for dw_dialog_dismiss() to be | |
1038 * called by a signal handler with the given dialog struct. | |
1039 * Parameters: | |
1040 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). | |
1041 */ | |
1042 void *dw_dialog_wait(DWDialog *dialog) | |
1043 { | |
1044 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
|
1045 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
|
1046 |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
1047 /* _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
|
1048 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
|
1049 { |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
1050 _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
|
1051 newprocess = 1; |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
1052 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
|
1053 } |
3 | 1054 |
1055 if(pthread_self() == _dw_thread) | |
1056 gtk_main(); | |
1057 else | |
1058 dw_event_wait(dialog->eve, -1); | |
1059 | |
41
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
1060 if(newprocess) |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
1061 { |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
1062 _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
|
1063 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
|
1064 } |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
1065 |
3 | 1066 dw_event_close(&dialog->eve); |
1067 tmp = dialog->result; | |
1068 free(dialog); | |
1069 return tmp; | |
1070 } | |
1071 | |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
1072 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
|
1073 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1074 DWDialog *dwwait = (DWDialog *)data; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1075 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1076 if(!dwwait) |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
1077 return FALSE; |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1078 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1079 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
|
1080 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
|
1081 return FALSE; |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1082 } |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1083 |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
1084 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
|
1085 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1086 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
|
1087 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1088 if(!dwwait) |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
1089 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
|
1090 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1091 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
|
1092 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
|
1093 return FALSE; |
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
1094 } |
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
1095 |
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
1096 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
|
1097 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1098 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
|
1099 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1100 if(!dwwait) |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
1101 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
|
1102 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1103 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
|
1104 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
|
1105 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
|
1106 } |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1107 |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1108 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
|
1109 { |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1110 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
|
1111 |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1112 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
|
1113 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
|
1114 |
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_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
|
1116 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
|
1117 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
|
1118 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1119 |
3 | 1120 /* |
1121 * Displays a Message Box with given text and title.. | |
1122 * Parameters: | |
1123 * 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
|
1124 * 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
|
1125 * 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
|
1126 * ...: 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
|
1127 */ |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1128 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
|
1129 { |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1130 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
|
1131 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
|
1132 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
|
1133 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
|
1134 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
|
1135 char **xpm_data = NULL; |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1136 int x, y; |
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 |
399
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1138 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
|
1139 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
|
1140 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
|
1141 |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1142 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
|
1143 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
|
1144 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
|
1145 |
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
|
1146 /* 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
|
1147 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
|
1148 { |
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
|
1149 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
|
1150 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
|
1151 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
|
1152 } |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1153 else |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1154 { |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1155 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
|
1156 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
|
1157 } |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1158 |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1159 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
|
1160 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
|
1161 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
|
1162 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
|
1163 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
|
1164 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
|
1165 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
|
1166 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
|
1167 |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1168 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
|
1169 { |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1170 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
|
1171 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
|
1172 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
|
1173 #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
|
1174 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
|
1175 |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1176 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
|
1177 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
|
1178 #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
|
1179 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
|
1180 #else |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1181 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
|
1182 #endif |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1183 |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1184 #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
|
1185 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
|
1186 #else |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1187 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
|
1188 #endif |
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 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
|
1191 } |
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 /* 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
|
1194 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
|
1195 dw_window_set_style(stext, DW_DT_WORDBREAK, DW_DT_WORDBREAK); |
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
|
1196 dw_box_pack_start(texttargetbox, stext, 235, 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
|
1197 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1198 /* 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
|
1199 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
|
1200 |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1201 dw_box_pack_start(mainbox, buttonbox, 0, 0, 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
|
1202 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1203 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
|
1204 |
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
|
1205 /* 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
|
1206 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
|
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 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
|
1209 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
|
1210 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
|
1211 } |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1212 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
|
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 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
|
1215 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
|
1216 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
|
1217 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
|
1218 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
|
1219 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
|
1220 } |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1221 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
|
1222 { |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1223 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
|
1224 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
|
1225 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
|
1226 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
|
1227 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
|
1228 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
|
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 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
|
1231 { |
a7a561103eac
Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
386
diff
changeset
|
1232 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
|
1233 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
|
1234 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
|
1235 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
|
1236 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
|
1237 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
|
1238 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
|
1239 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
|
1240 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
|
1241 } |
22
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 x = (dw_screen_width() - 280)/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
|
1244 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
|
1245 |
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
|
1246 dw_window_set_pos_size(entrywindow, x, y, 280, 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
|
1247 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1248 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
|
1249 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1250 return (int)dw_dialog_wait(dwwait);; |
3 | 1251 } |
1252 | |
1253 /* | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1254 * 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
|
1255 * Parameters: |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1256 * handle: The window handle to minimize. |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1257 */ |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1258 int dw_window_minimize(HWND handle) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1259 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1260 int _locked_by_me = FALSE; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1261 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1262 if(!handle) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1263 return 0; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1264 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1265 DW_MUTEX_LOCK; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1266 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
|
1267 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
|
1268 DefaultScreen (GDK_DISPLAY ())); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1269 DW_MUTEX_UNLOCK; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1270 return 0; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1271 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1272 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1273 /* |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1274 * Makes the window topmost. |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1275 * Parameters: |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1276 * 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
|
1277 */ |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1278 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
|
1279 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1280 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
|
1281 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1282 if(!handle) |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1283 return 0; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1284 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1285 DW_MUTEX_LOCK; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1286 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
|
1287 DW_MUTEX_UNLOCK; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1288 return 0; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1289 } |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1290 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1291 /* |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1292 * Makes the window bottommost. |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1293 * Parameters: |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1294 * 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
|
1295 */ |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1296 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
|
1297 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1298 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
|
1299 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1300 if(!handle) |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1301 return 0; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1302 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1303 DW_MUTEX_LOCK; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1304 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
|
1305 DW_MUTEX_UNLOCK; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1306 return 0; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1307 } |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1308 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1309 /* |
3 | 1310 * Makes the window visible. |
1311 * Parameters: | |
1312 * handle: The window handle to make visible. | |
1313 */ | |
1314 int dw_window_show(HWND handle) | |
1315 { | |
1316 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
|
1317 GtkWidget *defaultitem; |
3 | 1318 |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1319 if(!handle) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1320 return 0; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1321 |
3 | 1322 DW_MUTEX_LOCK; |
1323 gtk_widget_show(handle); | |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1324 if(GTK_WIDGET(handle)->window) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1325 { |
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
|
1326 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
|
1327 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
|
1328 |
49ac97060328
Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
271
diff
changeset
|
1329 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
|
1330 { |
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
|
1331 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
|
1332 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
|
1333 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
|
1334 } |
49ac97060328
Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
271
diff
changeset
|
1335 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1336 gdk_window_raise(GTK_WIDGET(handle)->window); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1337 gdk_flush(); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1338 gdk_window_show(GTK_WIDGET(handle)->window); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1339 gdk_flush(); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1340 } |
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
|
1341 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
|
1342 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
|
1343 gtk_widget_grab_focus(defaultitem); |
3 | 1344 DW_MUTEX_UNLOCK; |
1345 return 0; | |
1346 } | |
1347 | |
1348 /* | |
1349 * Makes the window invisible. | |
1350 * Parameters: | |
1351 * handle: The window handle to make visible. | |
1352 */ | |
1353 int dw_window_hide(HWND handle) | |
1354 { | |
1355 int _locked_by_me = FALSE; | |
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_hide(handle); | |
1362 DW_MUTEX_UNLOCK; | |
1363 return 0; | |
1364 } | |
1365 | |
1366 /* | |
1367 * Destroys a window and all of it's children. | |
1368 * Parameters: | |
1369 * handle: The window handle to destroy. | |
1370 */ | |
1371 int dw_window_destroy(HWND handle) | |
1372 { | |
1373 int _locked_by_me = FALSE; | |
1374 | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1375 if(!handle) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1376 return 0; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1377 |
3 | 1378 DW_MUTEX_LOCK; |
17
f26eced21a30
Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
15
diff
changeset
|
1379 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
|
1380 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
1381 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
|
1382 |
5df54ebc44dd
Fixed a bug where the eventbox associated with a box was not destroyed
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
355
diff
changeset
|
1383 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
|
1384 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
|
1385 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
|
1386 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
|
1387 } |
3 | 1388 DW_MUTEX_UNLOCK; |
1389 return 0; | |
1390 } | |
1391 | |
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
|
1392 /* 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
|
1393 * 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
|
1394 * 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
|
1395 */ |
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
|
1396 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
|
1397 { |
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
|
1398 } |
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
|
1399 |
3 | 1400 /* |
1401 * Changes a window's parent to newparent. | |
1402 * Parameters: | |
1403 * handle: The window handle to destroy. | |
1404 * newparent: The window's new parent window. | |
1405 */ | |
1406 void dw_window_reparent(HWND handle, HWND newparent) | |
1407 { | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1408 int _locked_by_me = FALSE; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1409 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1410 DW_MUTEX_LOCK; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1411 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
|
1412 DW_MUTEX_UNLOCK; |
3 | 1413 } |
1414 | |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
1415 static int _set_font(HWND handle, char *fontname) |
3 | 1416 { |
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
|
1417 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
|
1418 #if GTK_MAJOR_VERSION < 2 |
3 | 1419 GtkStyle *style; |
1420 GdkFont *font = NULL; | |
1421 | |
1422 font = gdk_font_load(fontname); | |
1423 | |
1424 if(font) | |
1425 { | |
1426 style = gtk_widget_get_style(handle); | |
1427 style->font = font; | |
1428 gtk_widget_set_style(handle, style); | |
1429 retval = TRUE; | |
1430 } | |
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
|
1431 #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
|
1432 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
|
1433 |
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
|
1434 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
|
1435 { |
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
|
1436 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
|
1437 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
|
1438 } |
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
|
1439 #endif |
3 | 1440 return retval; |
1441 } | |
1442 | |
1443 /* | |
1444 * Sets the font used by a specified window (widget) handle. | |
1445 * Parameters: | |
1446 * handle: The window (widget) handle. | |
1447 * fontname: Name and size of the font in the form "size.fontname" | |
1448 */ | |
1449 int dw_window_set_font(HWND handle, char *fontname) | |
1450 { | |
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
|
1451 #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
|
1452 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
|
1453 #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
|
1454 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
|
1455 #endif |
3 | 1456 GtkWidget *handle2 = handle; |
1457 char *font; | |
1458 int _locked_by_me = FALSE; | |
1459 gpointer data; | |
1460 | |
1461 DW_MUTEX_LOCK; | |
1462 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
1463 { | |
1464 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
1465 if(tmp) | |
1466 handle2 = tmp; | |
1467 } | |
1468 font = strdup(fontname); | |
1469 | |
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
|
1470 #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
|
1471 /* 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
|
1472 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
|
1473 if(gdkfont) |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1474 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
|
1475 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
|
1476 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
|
1477 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
|
1478 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
|
1479 #endif |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1480 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1481 /* 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
|
1482 data = gtk_object_get_data(GTK_OBJECT(handle2), "_dw_fontname"); |
3 | 1483 if(data) |
1484 free(data); | |
1485 | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
1486 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
|
1487 #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
|
1488 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
|
1489 |
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 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
|
1491 { |
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
|
1492 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
|
1493 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
|
1494 } |
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
|
1495 #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
|
1496 DW_MUTEX_UNLOCK; |
3 | 1497 return TRUE; |
1498 } | |
1499 | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1500 void _free_gdk_colors(HWND handle) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1501 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
1502 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
|
1503 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1504 if(old) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1505 free(old); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1506 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
1507 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
|
1508 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1509 if(old) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1510 free(old); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1511 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1512 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1513 /* 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
|
1514 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
|
1515 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1516 GdkColor *foregdk = malloc(sizeof(GdkColor)); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1517 GdkColor *backgdk = malloc(sizeof(GdkColor)); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1518 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1519 _free_gdk_colors(handle); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1520 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1521 *foregdk = fore; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1522 *backgdk = back; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
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(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
|
1525 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
|
1526 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1527 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
1528 static int _set_color(HWND handle, unsigned long fore, unsigned long back) |
3 | 1529 { |
155
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1530 /* 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
|
1531 * 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
|
1532 */ |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1533 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
|
1534 #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
|
1535 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
|
1536 #endif |
3 | 1537 |
155
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1538 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
|
1539 { |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1540 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
|
1541 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
|
1542 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
|
1543 forecolor.blue = DW_BLUE_VALUE(fore) << 8; |
3 | 1544 |
1545 gdk_color_alloc(_dw_cmap, &forecolor); | |
1546 | |
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
|
1547 #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
|
1548 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
|
1549 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
|
1550 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
|
1551 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
|
1552 #else |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1553 if(style) |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1554 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
|
1555 #endif |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1556 } |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1557 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
|
1558 { |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1559 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
|
1560 |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1561 #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
|
1562 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
|
1563 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
|
1564 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
|
1565 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
|
1566 #else |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1567 if(style) |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1568 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
|
1569 #endif |
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 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
|
1572 { |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1573 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
|
1574 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
|
1575 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
|
1576 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
|
1577 |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1578 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
|
1579 |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1580 #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
|
1581 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
|
1582 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
|
1583 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
|
1584 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
|
1585 #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
|
1586 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
|
1587 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
|
1588 #endif |
155
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1589 } |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1590 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
|
1591 { |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1592 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
|
1593 |
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
|
1594 #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
|
1595 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
|
1596 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
|
1597 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
|
1598 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
|
1599 #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
|
1600 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
|
1601 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
|
1602 #endif |
155
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1603 } |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1604 |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1605 _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
|
1606 |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1607 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
|
1608 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
1609 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
|
1610 |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1611 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
|
1612 { |
155
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1613 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
|
1614 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
|
1615 } |
3 | 1616 } |
1617 | |
155
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 < 2 |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1619 if(style) |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1620 { |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1621 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
|
1622 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
|
1623 } |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1624 #endif |
3 | 1625 return TRUE; |
1626 } | |
1627 /* | |
1628 * Sets the colors used by a specified window (widget) handle. | |
1629 * Parameters: | |
1630 * handle: The window (widget) handle. | |
1631 * fore: Foreground color in RGB format. | |
1632 * back: Background color in RGB format. | |
1633 */ | |
1634 int dw_window_set_color(HWND handle, unsigned long fore, unsigned long back) | |
1635 { | |
1636 GtkWidget *handle2 = handle; | |
1637 int _locked_by_me = FALSE; | |
1638 | |
1639 DW_MUTEX_LOCK; | |
1640 | |
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
|
1641 if(GTK_IS_SCROLLED_WINDOW(handle) || GTK_IS_BOX(handle)) |
3 | 1642 { |
1643 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
1644 if(tmp) | |
1645 handle2 = tmp; | |
1646 } | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1647 else if(GTK_IS_TABLE(handle)) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1648 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
1649 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
|
1650 if(tmp) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1651 handle2 = tmp; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1652 } |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1653 |
3 | 1654 _set_color(handle2, fore, back); |
1655 | |
1656 DW_MUTEX_UNLOCK; | |
1657 return TRUE; | |
1658 } | |
1659 | |
1660 /* | |
1661 * Sets the font used by a specified window (widget) handle. | |
1662 * Parameters: | |
1663 * handle: The window (widget) handle. | |
1664 * border: Size of the window border in pixels. | |
1665 */ | |
1666 int dw_window_set_border(HWND handle, int border) | |
1667 { | |
1668 /* TODO */ | |
1669 return 0; | |
1670 } | |
1671 | |
1672 /* | |
1673 * Captures the mouse input to this window. | |
1674 * Parameters: | |
1675 * handle: Handle to receive mouse input. | |
1676 */ | |
1677 void dw_window_capture(HWND handle) | |
1678 { | |
1679 int _locked_by_me = FALSE; | |
1680 | |
1681 DW_MUTEX_LOCK; | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1682 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 | 1683 DW_MUTEX_UNLOCK; |
1684 } | |
1685 | |
1686 /* | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1687 * 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
|
1688 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1689 * 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
|
1690 * 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
|
1691 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1692 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
|
1693 { |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1694 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
|
1695 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
|
1696 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1697 DW_MUTEX_LOCK; |
337
e9a424e641ff
Some pointer changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
331
diff
changeset
|
1698 if(pointertype & (1 << 31)) |
e9a424e641ff
Some pointer changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
331
diff
changeset
|
1699 { |
e9a424e641ff
Some pointer changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
331
diff
changeset
|
1700 GdkBitmap *bitmap = NULL; |
338 | 1701 GdkPixmap *pixmap = _find_private_pixmap(&bitmap, (pointertype & 0xFFFFFF), NULL, NULL); |
1702 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
|
1703 } |
e9a424e641ff
Some pointer changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
331
diff
changeset
|
1704 else |
e9a424e641ff
Some pointer changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
331
diff
changeset
|
1705 cursor = gdk_cursor_new(pointertype); |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
1706 if(handle && handle->window) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
1707 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
|
1708 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
|
1709 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
|
1710 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1711 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1712 /* |
3 | 1713 * Releases previous mouse capture. |
1714 */ | |
1715 void dw_window_release(void) | |
1716 { | |
1717 int _locked_by_me = FALSE; | |
1718 | |
1719 DW_MUTEX_LOCK; | |
1720 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
1721 DW_MUTEX_UNLOCK; | |
1722 } | |
1723 | |
1724 /* | |
1725 * Create a new Window Frame. | |
1726 * Parameters: | |
1727 * owner: The Owner's window handle or HWND_DESKTOP. | |
1728 * title: The Window title. | |
1729 * flStyle: Style flags, see the PM reference. | |
1730 */ | |
1731 HWND dw_window_new(HWND hwndOwner, char *title, unsigned long flStyle) | |
1732 { | |
1733 GtkWidget *tmp; | |
1734 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
|
1735 int flags = 0; |
3 | 1736 |
1737 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
|
1738 last_window = tmp = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
3 | 1739 |
1740 gtk_window_set_title(GTK_WINDOW(tmp), title); | |
1741 if(!(flStyle & DW_FCF_SIZEBORDER)) | |
1742 gtk_window_set_policy(GTK_WINDOW(tmp), FALSE, FALSE, TRUE); | |
1743 | |
1744 gtk_widget_realize(tmp); | |
1745 | |
1746 if(flStyle & DW_FCF_TITLEBAR) | |
1747 flags |= GDK_DECOR_TITLE; | |
1748 | |
1749 if(flStyle & DW_FCF_MINMAX) | |
1750 flags |= GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE; | |
1751 | |
1752 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
|
1753 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
|
1754 |
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
|
1755 if(flStyle & DW_FCF_BORDER || flStyle & DW_FCF_DLGBORDER) |
3 | 1756 flags |= GDK_DECOR_BORDER; |
1757 | |
1758 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
|
1759 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1760 if(hwndOwner) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1761 gdk_window_reparent(GTK_WIDGET(tmp)->window, GTK_WIDGET(hwndOwner)->window, 0, 0); |
3 | 1762 |
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
|
1763 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
|
1764 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
|
1765 |
3 | 1766 DW_MUTEX_UNLOCK; |
1767 return tmp; | |
1768 } | |
1769 | |
1770 /* | |
1771 * Create a new Box to be packed. | |
1772 * 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
|
1773 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal). |
3 | 1774 * pad: Number of pixels to pad around the box. |
1775 */ | |
1776 HWND dw_box_new(int type, int pad) | |
1777 { | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1778 GtkWidget *tmp, *eventbox; |
3 | 1779 int _locked_by_me = FALSE; |
1780 | |
1781 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
|
1782 tmp = gtk_table_new(1, 1, FALSE); |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1783 eventbox = gtk_event_box_new(); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1784 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1785 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
|
1786 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
|
1787 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
|
1788 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_boxpad", (gpointer)pad); |
3 | 1789 gtk_widget_show(tmp); |
1790 DW_MUTEX_UNLOCK; | |
1791 return tmp; | |
1792 } | |
1793 | |
1794 /* | |
1795 * Create a new Group Box to be packed. | |
1796 * 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
|
1797 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal). |
3 | 1798 * pad: Number of pixels to pad around the box. |
1799 * title: Text to be displayined in the group outline. | |
1800 */ | |
1801 HWND dw_groupbox_new(int type, int pad, char *title) | |
1802 { | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1803 GtkWidget *tmp, *frame; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1804 int _locked_by_me = FALSE; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1805 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1806 DW_MUTEX_LOCK; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1807 frame = gtk_frame_new(NULL); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1808 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
|
1809 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
|
1810 tmp = gtk_table_new(1, 1, FALSE); |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1811 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
|
1812 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
|
1813 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
|
1814 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
|
1815 gtk_container_add(GTK_CONTAINER(frame), tmp); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1816 gtk_widget_show(tmp); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1817 gtk_widget_show(frame); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1818 DW_MUTEX_UNLOCK; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1819 return frame; |
3 | 1820 } |
1821 | |
1822 /* | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1823 * 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
|
1824 * Parameters: |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1825 * 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
|
1826 */ |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1827 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
|
1828 { |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1829 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
|
1830 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
|
1831 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1832 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
|
1833 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
|
1834 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
|
1835 return tmp; |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1836 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1837 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1838 /* |
3 | 1839 * Create a bitmap object to be packed. |
1840 * 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
|
1841 * id: An ID to be used with dw_window_from_id() or 0L. |
3 | 1842 */ |
1843 HWND dw_bitmap_new(unsigned long id) | |
1844 { | |
121
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
1845 #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
|
1846 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
|
1847 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
|
1848 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
|
1849 "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
|
1850 " 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
|
1851 ". 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
|
1852 "."}; |
121
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
1853 #endif |
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
1854 GtkWidget *tmp; |
3 | 1855 int _locked_by_me = FALSE; |
1856 | |
1857 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
|
1858 #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
|
1859 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
|
1860 #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
|
1861 gdk_imlib_data_to_pixmap(test_xpm, &pixmap, &bitmap); |
3 | 1862 #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
|
1863 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
|
1864 |
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
|
1865 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
|
1866 pixmap = gdk_pixmap_create_from_xpm_d(last_window->window, &bitmap, &_colors[DW_CLR_PALEGRAY], test_xpm); |
3 | 1867 #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
|
1868 #if GTK_MAJOR_VERSION < 2 |
3 | 1869 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
|
1870 #endif |
3 | 1871 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
|
1872 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
3 | 1873 DW_MUTEX_UNLOCK; |
1874 return tmp; | |
1875 } | |
1876 | |
1877 /* | |
1878 * Create a notebook object to be packed. | |
1879 * Parameters: | |
1880 * id: An ID to be used for getting the resource from the | |
1881 * resource file. | |
1882 */ | |
1883 HWND dw_notebook_new(unsigned long id, int top) | |
1884 { | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1885 GtkWidget *tmp, **pagearray = calloc(sizeof(GtkWidget *), 256); |
3 | 1886 int _locked_by_me = FALSE; |
1887 | |
1888 DW_MUTEX_LOCK; | |
1889 tmp = gtk_notebook_new(); | |
1890 if(top) | |
1891 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(tmp), GTK_POS_TOP); | |
1892 else | |
1893 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
|
1894 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
|
1895 #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
|
1896 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
|
1897 #endif |
3 | 1898 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
|
1899 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
|
1900 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_pagearray", (gpointer)pagearray); |
3 | 1901 DW_MUTEX_UNLOCK; |
1902 return tmp; | |
1903 } | |
1904 | |
1905 /* | |
1906 * Create a menu object to be popped up. | |
1907 * Parameters: | |
1908 * id: An ID to be used for getting the resource from the | |
1909 * resource file. | |
1910 */ | |
1911 HMENUI dw_menu_new(unsigned long id) | |
1912 { | |
1913 int _locked_by_me = FALSE; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1914 GtkAccelGroup *accel_group; |
185
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
1915 HMENUI tmp; |
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
1916 |
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
1917 DW_MUTEX_LOCK; |
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
1918 tmp = gtk_menu_new(); |
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
1919 gtk_widget_show(tmp); |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1920 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
|
1921 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
|
1922 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_accel", (gpointer)accel_group); |
3 | 1923 DW_MUTEX_UNLOCK; |
1924 return tmp; | |
1925 } | |
1926 | |
1927 /* | |
1928 * Create a menubar on a window. | |
1929 * Parameters: | |
1930 * location: Handle of a window frame to be attached to. | |
1931 */ | |
1932 HMENUI dw_menubar_new(HWND location) | |
1933 { | |
1934 GtkWidget *box; | |
1935 int _locked_by_me = FALSE; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1936 GtkAccelGroup *accel_group; |
185
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
1937 HMENUI tmp; |
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
1938 |
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
1939 DW_MUTEX_LOCK; |
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
1940 tmp = gtk_menu_bar_new(); |
3 | 1941 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
|
1942 gtk_widget_show(tmp); |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1943 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
|
1944 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_accel", (gpointer)accel_group); |
3 | 1945 |
1946 if(box) | |
185
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
1947 gtk_box_pack_end(GTK_BOX(box), tmp, FALSE, FALSE, 0); |
3 | 1948 |
1949 DW_MUTEX_UNLOCK; | |
1950 return tmp; | |
1951 } | |
1952 | |
1953 /* | |
1954 * Destroys a menu created with dw_menubar_new or dw_menu_new. | |
1955 * Parameters: | |
1956 * menu: Handle of a menu. | |
1957 */ | |
1958 void dw_menu_destroy(HMENUI *menu) | |
1959 { | |
1960 if(menu && *menu) | |
1961 { | |
1962 int _locked_by_me = FALSE; | |
1963 | |
1964 DW_MUTEX_LOCK; | |
185
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
1965 gtk_widget_destroy(*menu); |
3 | 1966 *menu = NULL; |
1967 DW_MUTEX_UNLOCK; | |
1968 } | |
1969 } | |
1970 | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1971 char _removetilde(char *dest, char *src) |
3 | 1972 { |
1973 int z, cur=0; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1974 char accel = '\0'; |
3 | 1975 |
1976 for(z=0;z<strlen(src);z++) | |
1977 { | |
1978 if(src[z] != '~') | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1979 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1980 dest[cur] = src[z]; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1981 cur++; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1982 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1983 else |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1984 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1985 dest[cur] = '_'; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1986 accel = src[z+1]; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1987 cur++; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1988 } |
3 | 1989 } |
1990 dest[cur] = 0; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1991 return accel; |
3 | 1992 } |
1993 | |
1994 /* | |
1995 * Adds a menuitem or submenu to an existing menu. | |
1996 * Parameters: | |
1997 * menu: The handle the the existing menu. | |
1998 * title: The title text on the menu item to be added. | |
1999 * id: An ID to be used for message passing. | |
2000 * flags: Extended attributes to set on the menu. | |
2001 * end: If TRUE memu is positioned at the end of the menu. | |
2002 * check: If TRUE menu is "check"able. | |
2003 * submenu: Handle to an existing menu to be a submenu or NULL. | |
2004 */ | |
2005 HWND dw_menu_append_item(HMENUI menu, char *title, unsigned long id, unsigned long flags, int end, int check, HMENUI submenu) | |
2006 { | |
2007 GtkWidget *tmphandle; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2008 char accel, *tempbuf = malloc(strlen(title)+1); |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2009 int _locked_by_me = FALSE, submenucount; |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2010 guint tmp_key; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2011 GtkAccelGroup *accel_group; |
3 | 2012 |
185
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
2013 if(!menu) |
3 | 2014 { |
2015 free(tempbuf); | |
2016 return NULL; | |
2017 } | |
2018 | |
2019 DW_MUTEX_LOCK; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2020 accel = _removetilde(tempbuf, title); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2021 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2022 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
|
2023 submenucount = (int)gtk_object_get_data(GTK_OBJECT(menu), "_dw_submenucount"); |
3 | 2024 |
2025 if(strlen(tempbuf) == 0) | |
2026 tmphandle=gtk_menu_item_new(); | |
2027 else | |
2028 { | |
2029 if(check) | |
2030 { | |
2031 char numbuf[10]; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2032 if(accel && accel_group) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2033 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2034 tmphandle=gtk_check_menu_item_new_with_label(""); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2035 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
|
2036 #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
|
2037 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
|
2038 #endif |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2039 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2040 else |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2041 tmphandle=gtk_check_menu_item_new_with_label(tempbuf); |
3 | 2042 gtk_check_menu_item_set_show_toggle(GTK_CHECK_MENU_ITEM(tmphandle), TRUE); |
2043 sprintf(numbuf, "%lu", id); | |
185
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
2044 gtk_object_set_data(GTK_OBJECT(menu), numbuf, (gpointer)tmphandle); |
3 | 2045 } |
2046 else | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2047 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2048 if(accel && accel_group) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2049 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2050 tmphandle=gtk_menu_item_new_with_label(""); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2051 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
|
2052 #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
|
2053 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
|
2054 #endif |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2055 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2056 else |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2057 tmphandle=gtk_menu_item_new_with_label(tempbuf); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2058 } |
3 | 2059 } |
2060 | |
2061 gtk_widget_show(tmphandle); | |
2062 | |
2063 if(submenu) | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2064 { |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2065 char tempbuf[100]; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2066 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2067 sprintf(tempbuf, "_dw_submenu%d", submenucount); |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2068 submenucount++; |
185
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
2069 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
|
2070 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
|
2071 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
|
2072 } |
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
2073 |
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
2074 if(GTK_IS_MENU_BAR(menu)) |
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
2075 gtk_menu_bar_append(GTK_MENU_BAR(menu), tmphandle); |
3 | 2076 else |
185
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
2077 gtk_menu_append(GTK_MENU(menu), tmphandle); |
3 | 2078 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2079 gtk_object_set_data(GTK_OBJECT(tmphandle), "_dw_id", (gpointer)id); |
3 | 2080 free(tempbuf); |
2081 DW_MUTEX_UNLOCK; | |
2082 return tmphandle; | |
2083 } | |
2084 | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2085 GtkWidget *_find_submenu_id(GtkWidget *start, char *name) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2086 { |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2087 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
|
2088 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
|
2089 |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2090 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
|
2091 return tmp; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2092 |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2093 for(z=0;z<submenucount;z++) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2094 { |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2095 char tempbuf[100]; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2096 GtkWidget *submenu, *menuitem; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2097 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2098 sprintf(tempbuf, "_dw_submenu%d", z); |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2099 |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2100 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
|
2101 { |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2102 if((menuitem = _find_submenu_id(submenu, name))) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2103 return menuitem; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2104 } |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2105 } |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2106 return NULL; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2107 } |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2108 |
3 | 2109 /* |
2110 * Sets the state of a menu item check. | |
2111 * Parameters: | |
2112 * menu: The handle the the existing menu. | |
2113 * id: Menuitem id. | |
2114 * check: TRUE for checked FALSE for not checked. | |
2115 */ | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2116 void dw_menu_item_set_check(HMENUI menu, unsigned long id, int check) |
3 | 2117 { |
2118 char numbuf[10]; | |
2119 GtkWidget *tmphandle; | |
2120 int _locked_by_me = FALSE; | |
2121 | |
185
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
2122 if(!menu) |
3 | 2123 return; |
2124 | |
2125 DW_MUTEX_LOCK; | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2126 sprintf(numbuf, "%lu", id); |
185
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
2127 tmphandle = _find_submenu_id(menu, numbuf); |
3 | 2128 |
2129 if(tmphandle) | |
2130 { | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2131 _dw_ignore_click = 1; |
3 | 2132 if(GTK_CHECK_MENU_ITEM(tmphandle)->active != check) |
2133 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
|
2134 _dw_ignore_click = 0; |
3 | 2135 } |
2136 DW_MUTEX_UNLOCK; | |
2137 } | |
2138 | |
2139 /* | |
2140 * Pops up a context menu at given x and y coordinates. | |
2141 * Parameters: | |
2142 * menu: The handle the the existing menu. | |
2143 * parent: Handle to the window initiating the popup. | |
2144 * x: X coordinate. | |
2145 * y: Y coordinate. | |
2146 */ | |
2147 void dw_menu_popup(HMENUI *menu, HWND parent, int x, int y) | |
2148 { | |
2149 int _locked_by_me = FALSE; | |
2150 | |
2151 if(!menu || !*menu) | |
2152 return; | |
2153 | |
93
98cce029a611
Changed handling of menu item click events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
92
diff
changeset
|
2154 popup = parent; |
98cce029a611
Changed handling of menu item click events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
92
diff
changeset
|
2155 |
3 | 2156 DW_MUTEX_LOCK; |
185
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
2157 gtk_menu_popup(GTK_MENU(*menu), NULL, NULL, NULL, NULL, 1, GDK_CURRENT_TIME); |
3 | 2158 *menu = NULL; |
2159 DW_MUTEX_UNLOCK; | |
2160 } | |
2161 | |
2162 | |
2163 /* | |
2164 * Returns the current X and Y coordinates of the mouse pointer. | |
2165 * Parameters: | |
2166 * x: Pointer to variable to store X coordinate. | |
2167 * y: Pointer to variable to store Y coordinate. | |
2168 */ | |
2169 void dw_pointer_query_pos(long *x, long *y) | |
2170 { | |
2171 GdkModifierType state; | |
2172 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
|
2173 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
|
2174 |
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
|
2175 DW_MUTEX_LOCK; |
3 | 2176 gdk_window_get_pointer (GDK_ROOT_PARENT(), &gx, &gy, &state); |
2177 *x = gx; | |
2178 *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
|
2179 DW_MUTEX_UNLOCK; |
3 | 2180 } |
2181 | |
2182 /* | |
2183 * Sets the X and Y coordinates of the mouse pointer. | |
2184 * Parameters: | |
2185 * x: X coordinate. | |
2186 * y: Y coordinate. | |
2187 */ | |
2188 void dw_pointer_set_pos(long x, long y) | |
2189 { | |
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
|
2190 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
|
2191 |
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
|
2192 DW_MUTEX_LOCK; |
3 | 2193 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
|
2194 DW_MUTEX_UNLOCK; |
3 | 2195 } |
2196 | |
2197 /* | |
2198 * Create a container object to be packed. | |
2199 * Parameters: | |
2200 * id: An ID to be used for getting the resource from the | |
2201 * resource file. | |
2202 */ | |
350
2216e65ad2ae
Removed slider flags and container selection flags from the header file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
346
diff
changeset
|
2203 HWND dw_container_new(unsigned long id, int multi) |
3 | 2204 { |
2205 GtkWidget *tmp; | |
2206 int _locked_by_me = FALSE; | |
2207 | |
2208 DW_MUTEX_LOCK; | |
2209 tmp = gtk_scrolled_window_new (NULL, NULL); | |
2210 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (tmp), | |
2211 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
2212 | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2213 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
|
2214 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
3 | 2215 gtk_widget_show(tmp); |
2216 | |
2217 DW_MUTEX_UNLOCK; | |
2218 return tmp; | |
2219 } | |
2220 | |
2221 /* | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2222 * 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
|
2223 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2224 * 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
|
2225 * 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
|
2226 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2227 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
|
2228 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2229 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
|
2230 #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
|
2231 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
|
2232 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
|
2233 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
|
2234 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
|
2235 #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
|
2236 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
|
2237 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2238 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
|
2239 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
|
2240 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
|
2241 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
|
2242 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2243 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
|
2244 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
|
2245 #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
|
2246 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
|
2247 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
|
2248 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
|
2249 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
|
2250 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
2251 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
|
2252 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
|
2253 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
|
2254 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
|
2255 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
|
2256 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
|
2257 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
2258 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
|
2259 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
|
2260 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
|
2261 |
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
|
2262 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
|
2263 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
|
2264 #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
|
2265 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
|
2266 #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
|
2267 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
|
2268 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2269 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
|
2270 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
|
2271 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
|
2272 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2273 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
|
2274 #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
|
2275 /* 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
|
2276 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
|
2277 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
|
2278 #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
|
2279 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2280 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
|
2281 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
|
2282 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2283 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
|
2284 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
|
2285 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2286 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2287 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2288 /* |
3 | 2289 * Create a new static text window (widget) to be packed. |
2290 * Parameters: | |
2291 * 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
|
2292 * id: An ID to be used with dw_window_from_id() or 0L. |
3 | 2293 */ |
2294 HWND dw_text_new(char *text, unsigned long id) | |
2295 { | |
2296 GtkWidget *tmp; | |
2297 int _locked_by_me = FALSE; | |
2298 | |
2299 DW_MUTEX_LOCK; | |
2300 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
|
2301 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2302 /* 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
|
2303 gtk_misc_set_alignment(GTK_MISC(tmp), 0.0f, 0.5f); |
3 | 2304 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
|
2305 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
|
2306 gtk_misc_set_alignment(GTK_MISC(tmp), DW_LEFT, DW_LEFT); |
3 | 2307 DW_MUTEX_UNLOCK; |
2308 return tmp; | |
2309 } | |
2310 | |
2311 /* | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2312 * 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
|
2313 * Parameters: |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2314 * 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
|
2315 * 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
|
2316 */ |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2317 HWND dw_status_text_new(char *text, ULONG id) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2318 { |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2319 GtkWidget *tmp, *frame; |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2320 int _locked_by_me = FALSE; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2321 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2322 DW_MUTEX_LOCK; |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2323 frame = gtk_frame_new(NULL); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2324 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
|
2325 tmp = gtk_label_new(text); |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2326 gtk_container_add(GTK_CONTAINER(frame), tmp); |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2327 gtk_widget_show(tmp); |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2328 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
|
2329 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2330 /* 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
|
2331 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
|
2332 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
|
2333 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
|
2334 DW_MUTEX_UNLOCK; |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2335 return frame; |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2336 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2337 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2338 /* |
3 | 2339 * Create a new Multiline Editbox window (widget) to be packed. |
2340 * 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
|
2341 * id: An ID to be used with dw_window_from_id() or 0L. |
3 | 2342 */ |
2343 HWND dw_mle_new(unsigned long id) | |
2344 { | |
2345 GtkWidget *tmp, *tmpbox, *scroller; | |
2346 int _locked_by_me = FALSE; | |
2347 | |
2348 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
|
2349 #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
|
2350 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
|
2351 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
|
2352 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
|
2353 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
|
2354 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
|
2355 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
|
2356 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
|
2357 |
122
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
2358 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
|
2359 #else |
3 | 2360 tmpbox = gtk_hbox_new(FALSE, 0); |
2361 tmp = gtk_text_new(NULL, NULL); | |
2362 gtk_text_set_word_wrap(GTK_TEXT(tmp), FALSE); | |
2363 gtk_text_set_line_wrap(GTK_TEXT(tmp), FALSE); | |
2364 scroller = gtk_vscrollbar_new(GTK_TEXT(tmp)->vadj); | |
2365 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
|
2366 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
|
2367 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
|
2368 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
|
2369 #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
|
2370 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
|
2371 gtk_object_set_user_data(GTK_OBJECT(tmpbox), (gpointer)tmp); |
3 | 2372 gtk_widget_show(tmp); |
2373 gtk_widget_show(tmpbox); | |
2374 DW_MUTEX_UNLOCK; | |
2375 return tmpbox; | |
2376 } | |
2377 | |
2378 /* | |
2379 * Create a new Entryfield window (widget) to be packed. | |
2380 * Parameters: | |
2381 * 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
|
2382 * id: An ID to be used with dw_window_from_id() or 0L. |
3 | 2383 */ |
2384 HWND dw_entryfield_new(char *text, unsigned long id) | |
2385 { | |
2386 GtkWidget *tmp; | |
2387 int _locked_by_me = FALSE; | |
2388 | |
2389 DW_MUTEX_LOCK; | |
2390 tmp = gtk_entry_new(); | |
2391 | |
2392 gtk_entry_set_text(GTK_ENTRY(tmp), text); | |
2393 | |
2394 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
|
2395 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
3 | 2396 |
2397 DW_MUTEX_UNLOCK; | |
2398 return tmp; | |
2399 } | |
2400 | |
2401 /* | |
2402 * Create a new Entryfield (password) window (widget) to be packed. | |
2403 * Parameters: | |
2404 * 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
|
2405 * id: An ID to be used with dw_window_from_id() or 0L. |
3 | 2406 */ |
2407 HWND dw_entryfield_password_new(char *text, ULONG id) | |
2408 { | |
2409 GtkWidget *tmp; | |
2410 int _locked_by_me = FALSE; | |
2411 | |
2412 DW_MUTEX_LOCK; | |
2413 tmp = gtk_entry_new(); | |
2414 | |
2415 gtk_entry_set_visibility(GTK_ENTRY(tmp), FALSE); | |
2416 gtk_entry_set_text(GTK_ENTRY(tmp), text); | |
2417 | |
2418 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
|
2419 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
3 | 2420 |
2421 DW_MUTEX_UNLOCK; | |
2422 return tmp; | |
2423 } | |
2424 | |
2425 /* | |
2426 * Create a new Combobox window (widget) to be packed. | |
2427 * Parameters: | |
2428 * 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
|
2429 * id: An ID to be used with dw_window_from_id() or 0L. |
3 | 2430 */ |
2431 HWND dw_combobox_new(char *text, unsigned long id) | |
2432 { | |
2433 GtkWidget *tmp; | |
115
2d121d4d90c0
Run the _item_select_event() handler on comboboxes even if a handler
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
114
diff
changeset
|
2434 SignalHandler *work = malloc(sizeof(SignalHandler)); |
3 | 2435 int _locked_by_me = FALSE; |
2436 | |
2437 DW_MUTEX_LOCK; | |
2438 tmp = gtk_combo_new(); | |
2439 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(tmp)->entry), text); | |
2440 gtk_combo_set_use_arrows(GTK_COMBO(tmp), TRUE); | |
2441 gtk_object_set_user_data(GTK_OBJECT(tmp), NULL); | |
2442 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
|
2443 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
|
2444 |
2d121d4d90c0
Run the _item_select_event() handler on comboboxes even if a handler
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
114
diff
changeset
|
2445 work->window = tmp; |
2d121d4d90c0
Run the _item_select_event() handler on comboboxes even if a handler
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
114
diff
changeset
|
2446 work->func = NULL; |
2d121d4d90c0
Run the _item_select_event() handler on comboboxes even if a handler
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
114
diff
changeset
|
2447 work->data = NULL; |
2d121d4d90c0
Run the _item_select_event() handler on comboboxes even if a handler
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
114
diff
changeset
|
2448 |
2d121d4d90c0
Run the _item_select_event() handler on comboboxes even if a handler
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
114
diff
changeset
|
2449 gtk_signal_connect(GTK_OBJECT(GTK_COMBO(tmp)->list), "select_child", GTK_SIGNAL_FUNC(_item_select_event), work); |
3 | 2450 DW_MUTEX_UNLOCK; |
2451 return tmp; | |
2452 } | |
2453 | |
2454 /* | |
2455 * Create a new button window (widget) to be packed. | |
2456 * Parameters: | |
2457 * 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
|
2458 * id: An ID to be used with dw_window_from_id() or 0L. |
3 | 2459 */ |
2460 HWND dw_button_new(char *text, unsigned long id) | |
2461 { | |
2462 GtkWidget *tmp; | |
2463 int _locked_by_me = FALSE; | |
2464 | |
2465 DW_MUTEX_LOCK; | |
2466 tmp = gtk_button_new_with_label(text); | |
2467 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
|
2468 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
3 | 2469 DW_MUTEX_UNLOCK; |
2470 return tmp; | |
2471 } | |
2472 | |
2473 /* | |
2474 * Create a new bitmap button window (widget) to be packed. | |
2475 * Parameters: | |
2476 * text: Bubble help text to be displayed. | |
2477 * id: An ID of a bitmap in the resource file. | |
2478 */ | |
2479 HWND dw_bitmapbutton_new(char *text, unsigned long id) | |
2480 { | |
2481 GtkWidget *tmp; | |
2482 GtkWidget *bitmap; | |
2483 GtkTooltips *tooltips; | |
2484 int _locked_by_me = FALSE; | |
2485 | |
2486 DW_MUTEX_LOCK; | |
2487 tmp = gtk_button_new(); | |
2488 bitmap = dw_bitmap_new(id); | |
2489 | |
2490 if(bitmap) | |
2491 { | |
278
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2492 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
|
2493 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
|
2494 } |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2495 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
|
2496 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
|
2497 { |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2498 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
|
2499 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
|
2500 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
|
2501 } |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2502 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
|
2503 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
|
2504 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
|
2505 } |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2506 |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2507 /* |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2508 * 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
|
2509 * Parameters: |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2510 * 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
|
2511 * 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
|
2512 * 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
|
2513 * 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
|
2514 * (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
|
2515 */ |
279
984db8aefd7f
Build fixes for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
278
diff
changeset
|
2516 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
|
2517 { |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2518 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
|
2519 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
|
2520 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
|
2521 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
|
2522 |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2523 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
|
2524 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
|
2525 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
|
2526 |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2527 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
|
2528 { |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2529 dw_window_set_bitmap(bitmap, 0, filename); |
3 | 2530 gtk_container_add (GTK_CONTAINER(tmp), bitmap); |
2531 } | |
2532 gtk_widget_show(tmp); | |
2533 if(text) | |
2534 { | |
2535 tooltips = gtk_tooltips_new(); | |
2536 gtk_tooltips_set_tip(tooltips, tmp, text, NULL); | |
2537 gtk_object_set_data(GTK_OBJECT(tmp), "tooltip", (gpointer)tooltips); | |
2538 } | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2539 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
3 | 2540 DW_MUTEX_UNLOCK; |
2541 return tmp; | |
2542 } | |
2543 | |
2544 /* | |
2545 * Create a new spinbutton window (widget) to be packed. | |
2546 * Parameters: | |
2547 * 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
|
2548 * id: An ID to be used with dw_window_from_id() or 0L. |
3 | 2549 */ |
2550 HWND dw_spinbutton_new(char *text, unsigned long id) | |
2551 { | |
2552 GtkAdjustment *adj; | |
2553 GtkWidget *tmp; | |
2554 int _locked_by_me = FALSE; | |
2555 | |
2556 DW_MUTEX_LOCK; | |
2557 adj = (GtkAdjustment *)gtk_adjustment_new (1.0, 0.0, 100.0, 1.0, 5.0, 0.0); | |
2558 tmp = gtk_spin_button_new (adj, 0, 0); | |
2559 gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(tmp), TRUE); | |
2560 gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(tmp), TRUE); | |
2561 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
|
2562 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
3 | 2563 DW_MUTEX_UNLOCK; |
2564 return tmp; | |
2565 } | |
2566 | |
2567 /* | |
2568 * Create a new radiobutton window (widget) to be packed. | |
2569 * Parameters: | |
2570 * 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
|
2571 * id: An ID to be used with dw_window_from_id() or 0L. |
3 | 2572 */ |
2573 HWND dw_radiobutton_new(char *text, ULONG id) | |
2574 { | |
2575 /* This will have to be fixed in the future. */ | |
2576 GtkWidget *tmp; | |
2577 int _locked_by_me = FALSE; | |
2578 | |
2579 DW_MUTEX_LOCK; | |
2580 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
|
2581 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
3 | 2582 gtk_widget_show(tmp); |
2583 | |
2584 DW_MUTEX_UNLOCK; | |
2585 return tmp; | |
2586 } | |
2587 | |
2588 /* | |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2589 * 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
|
2590 * Parameters: |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2591 * 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
|
2592 * 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
|
2593 * 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
|
2594 */ |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2595 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
|
2596 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2597 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
|
2598 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
|
2599 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
|
2600 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2601 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
|
2602 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
|
2603 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
|
2604 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
|
2605 else |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2606 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
|
2607 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
|
2608 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
|
2609 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
|
2610 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
|
2611 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
|
2612 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
|
2613 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
|
2614 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
|
2615 } |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2616 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2617 /* |
195
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2618 * 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
|
2619 * Parameters: |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2620 * 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
|
2621 * 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
|
2622 * 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
|
2623 */ |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2624 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
|
2625 { |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2626 GtkWidget *tmp; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2627 GtkAdjustment *adjustment; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2628 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
|
2629 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2630 DW_MUTEX_LOCK; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2631 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
|
2632 if(vertical) |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2633 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
|
2634 else |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2635 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
|
2636 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
|
2637 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
|
2638 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
|
2639 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
|
2640 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
|
2641 DW_MUTEX_UNLOCK; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2642 return tmp; |
196
3dc60d60007f
Fixed a missing bracket.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
195
diff
changeset
|
2643 } |
195
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2644 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2645 /* |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
2646 * Create a new percent bar window (widget) to be packed. |
3 | 2647 * 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
|
2648 * id: An ID to be used with dw_window_from_id() or 0L. |
3 | 2649 */ |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
2650 HWND dw_percent_new(unsigned long id) |
3 | 2651 { |
2652 GtkWidget *tmp; | |
2653 int _locked_by_me = FALSE; | |
2654 | |
2655 DW_MUTEX_LOCK; | |
2656 tmp = gtk_progress_bar_new(); | |
2657 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
|
2658 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
3 | 2659 DW_MUTEX_UNLOCK; |
2660 return tmp; | |
2661 } | |
2662 | |
2663 /* | |
2664 * Create a new checkbox window (widget) to be packed. | |
2665 * Parameters: | |
2666 * 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
|
2667 * id: An ID to be used with dw_window_from_id() or 0L. |
3 | 2668 */ |
2669 HWND dw_checkbox_new(char *text, unsigned long id) | |
2670 { | |
2671 GtkWidget *tmp; | |
2672 int _locked_by_me = FALSE; | |
2673 | |
2674 DW_MUTEX_LOCK; | |
2675 tmp = gtk_check_button_new_with_label(text); | |
2676 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
|
2677 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
3 | 2678 DW_MUTEX_UNLOCK; |
2679 return tmp; | |
2680 } | |
2681 | |
2682 /* | |
2683 * Create a new listbox window (widget) to be packed. | |
2684 * 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
|
2685 * id: An ID to be used with dw_window_from_id() or 0L. |
3 | 2686 * multi: Multiple select TRUE or FALSE. |
2687 */ | |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2688 HWND dw_listbox_new(unsigned long id, int multi) |
3 | 2689 { |
2690 GtkWidget *tmp, *list; | |
2691 int _locked_by_me = FALSE; | |
2692 | |
2693 DW_MUTEX_LOCK; | |
2694 tmp = gtk_scrolled_window_new(NULL, NULL); | |
2695 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (tmp), | |
2696 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
2697 | |
2698 list = gtk_list_new(); | |
2699 gtk_list_set_selection_mode(GTK_LIST(list), multi ? GTK_SELECTION_MULTIPLE : GTK_SELECTION_SINGLE); | |
2700 | |
2701 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(tmp), | |
2702 list); | |
2703 gtk_object_set_user_data(GTK_OBJECT(tmp), list); | |
2704 gtk_widget_show(list); | |
2705 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
|
2706 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
3 | 2707 |
2708 DW_MUTEX_UNLOCK; | |
2709 return tmp; | |
2710 } | |
2711 | |
2712 /* | |
2713 * Sets the icon used for a given window. | |
2714 * Parameters: | |
2715 * handle: Handle to the window. | |
2716 * id: An ID to be used to specify the icon. | |
2717 */ | |
2718 void dw_window_set_icon(HWND handle, unsigned long id) | |
2719 { | |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2720 GdkBitmap *bitmap = NULL; |
3 | 2721 GdkPixmap *icon_pixmap; |
2722 int _locked_by_me = FALSE; | |
2723 | |
2724 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
|
2725 icon_pixmap = _find_pixmap(&bitmap, id, handle, NULL, NULL); |
3 | 2726 |
2727 if(handle->window && icon_pixmap) | |
2728 gdk_window_set_icon(handle->window, NULL, icon_pixmap, bitmap); | |
2729 | |
2730 DW_MUTEX_UNLOCK; | |
2731 } | |
2732 | |
2733 /* | |
2734 * Sets the bitmap used for a given static window. | |
2735 * Parameters: | |
2736 * 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
|
2737 * 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
|
2738 * (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
|
2739 * 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
|
2740 * 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
|
2741 * 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
|
2742 */ |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2743 void dw_window_set_bitmap(HWND handle, unsigned long id, char *filename) |
3 | 2744 { |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2745 GdkBitmap *bitmap = NULL; |
3 | 2746 GdkPixmap *tmp; |
2747 int _locked_by_me = FALSE; | |
2748 | |
278
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2749 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
|
2750 return; |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2751 |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2752 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
|
2753 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
|
2754 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
|
2755 else |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2756 { |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2757 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
|
2758 #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
|
2759 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
|
2760 #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
|
2761 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
|
2762 #endif |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2763 |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2764 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
|
2765 { |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2766 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
|
2767 return; |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2768 } |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2769 |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2770 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
|
2771 |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2772 /* 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
|
2773 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
|
2774 { |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2775 /* 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
|
2776 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
|
2777 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
|
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 DW_MUTEX_UNLOCK; |
279
984db8aefd7f
Build fixes for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
278
diff
changeset
|
2780 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
|
2781 } |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2782 } |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2783 #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
|
2784 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
|
2785 |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2786 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
|
2787 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
|
2788 #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
|
2789 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
|
2790 |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2791 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
|
2792 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
|
2793 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
|
2794 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
|
2795 #else |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2796 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
|
2797 #endif |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2798 } |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2799 |
3 | 2800 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
|
2801 #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
|
2802 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
|
2803 #else |
3 | 2804 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
|
2805 #endif |
3 | 2806 DW_MUTEX_UNLOCK; |
2807 } | |
2808 | |
2809 /* | |
2810 * Sets the text used for a given window. | |
2811 * Parameters: | |
2812 * handle: Handle to the window. | |
2813 * text: The text associsated with a given window. | |
2814 */ | |
2815 void dw_window_set_text(HWND handle, char *text) | |
2816 { | |
2817 int _locked_by_me = FALSE; | |
2818 | |
2819 DW_MUTEX_LOCK; | |
2820 if(GTK_IS_ENTRY(handle)) | |
2821 gtk_entry_set_text(GTK_ENTRY(handle), text); | |
2822 else if(GTK_IS_COMBO(handle)) | |
2823 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(handle)->entry), text); | |
2824 else if(GTK_IS_LABEL(handle)) | |
2825 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
|
2826 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
|
2827 { |
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
|
2828 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
|
2829 |
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
|
2830 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
|
2831 gtk_label_set_text(GTK_LABEL(label), text); |
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
|
2832 } |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2833 else if(GTK_IS_FRAME(handle)) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2834 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2835 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
|
2836 if(tmp && GTK_IS_LABEL(tmp)) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2837 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
|
2838 } |
3 | 2839 DW_MUTEX_UNLOCK; |
2840 } | |
2841 | |
2842 /* | |
2843 * Gets the text used for a given window. | |
2844 * Parameters: | |
2845 * handle: Handle to the window. | |
2846 * Returns: | |
2847 * text: The text associsated with a given window. | |
2848 */ | |
2849 char *dw_window_get_text(HWND handle) | |
2850 { | |
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
|
2851 #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
|
2852 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
|
2853 #else |
3 | 2854 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
|
2855 #endif |
3 | 2856 int _locked_by_me = FALSE; |
2857 | |
2858 DW_MUTEX_LOCK; | |
2859 if(GTK_IS_ENTRY(handle)) | |
2860 possible = gtk_entry_get_text(GTK_ENTRY(handle)); | |
2861 else if(GTK_IS_COMBO(handle)) | |
2862 possible = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(handle)->entry)); | |
2863 | |
2864 DW_MUTEX_UNLOCK; | |
2865 return strdup(possible); | |
2866 } | |
2867 | |
2868 /* | |
2869 * Disables given window (widget). | |
2870 * Parameters: | |
2871 * handle: Handle to the window. | |
2872 */ | |
2873 void dw_window_disable(HWND handle) | |
2874 { | |
2875 int _locked_by_me = FALSE; | |
2876 | |
2877 DW_MUTEX_LOCK; | |
2878 gtk_widget_set_sensitive(handle, FALSE); | |
2879 DW_MUTEX_UNLOCK; | |
2880 } | |
2881 | |
2882 /* | |
2883 * Enables given window (widget). | |
2884 * Parameters: | |
2885 * handle: Handle to the window. | |
2886 */ | |
2887 void dw_window_enable(HWND handle) | |
2888 { | |
2889 int _locked_by_me = FALSE; | |
2890 | |
2891 DW_MUTEX_LOCK; | |
2892 gtk_widget_set_sensitive(handle, TRUE); | |
2893 DW_MUTEX_UNLOCK; | |
2894 } | |
2895 | |
249
5a594058687f
Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
246
diff
changeset
|
2896 /* |
5a594058687f
Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
246
diff
changeset
|
2897 * 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
|
2898 * Parameters: |
5a594058687f
Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
246
diff
changeset
|
2899 * 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
|
2900 * 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
|
2901 */ |
5a594058687f
Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
246
diff
changeset
|
2902 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
|
2903 { |
267
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2904 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
|
2905 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
|
2906 |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2907 DW_MUTEX_LOCK; |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2908 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
|
2909 { |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2910 #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
|
2911 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
|
2912 #else |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2913 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
|
2914 #endif |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2915 } |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2916 while(list) |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2917 { |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2918 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
|
2919 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2920 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
|
2921 { |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2922 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
|
2923 g_list_free(orig); |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2924 DW_MUTEX_UNLOCK; |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2925 return ret; |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2926 } |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2927 } |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2928 list = list->next; |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2929 } |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2930 if(orig) |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2931 g_list_free(orig); |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2932 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
|
2933 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
|
2934 } |
5a594058687f
Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
246
diff
changeset
|
2935 |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2936 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
|
2937 { |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2938 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
|
2939 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2940 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
|
2941 { |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2942 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
|
2943 { |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2944 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
|
2945 x++; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2946 } |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2947 } |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2948 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
|
2949 } |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2950 |
3 | 2951 /* |
2952 * Adds text to an MLE box and returns the current point. | |
2953 * Parameters: | |
2954 * handle: Handle to the MLE to be queried. | |
2955 * buffer: Text buffer to be imported. | |
2956 * startpoint: Point to start entering text. | |
2957 */ | |
2958 unsigned int dw_mle_import(HWND handle, char *buffer, int startpoint) | |
2959 { | |
2960 unsigned int tmppoint = startpoint; | |
2961 int _locked_by_me = FALSE; | |
2962 | |
2963 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
|
2964 #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
|
2965 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
|
2966 #else |
3 | 2967 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
|
2968 #endif |
3 | 2969 { |
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
|
2970 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 2971 |
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
|
2972 #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
|
2973 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
|
2974 { |
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
|
2975 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
|
2976 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
|
2977 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
|
2978 |
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
|
2979 _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
|
2980 |
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
|
2981 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
|
2982 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
|
2983 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
|
2984 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
|
2985 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
|
2986 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
|
2987 } |
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
|
2988 #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
|
2989 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
|
2990 |
3 | 2991 if(tmp && GTK_IS_TEXT(tmp)) |
2992 { | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2993 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
|
2994 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
|
2995 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
|
2996 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2997 _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
|
2998 |
3 | 2999 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
|
3000 gtk_text_insert(GTK_TEXT(tmp), font, fore, back, impbuf, -1); |
3 | 3001 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
|
3002 free(impbuf); |
3 | 3003 } |
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
|
3004 #endif |
3 | 3005 } |
3006 DW_MUTEX_UNLOCK; | |
3007 return tmppoint; | |
3008 } | |
3009 | |
3010 /* | |
3011 * Grabs text from an MLE box. | |
3012 * Parameters: | |
3013 * handle: Handle to the MLE to be queried. | |
3014 * buffer: Text buffer to be exported. | |
3015 * startpoint: Point to start grabbing text. | |
3016 * length: Amount of text to be grabbed. | |
3017 */ | |
3018 void dw_mle_export(HWND handle, char *buffer, int startpoint, int length) | |
3019 { | |
3020 int _locked_by_me = FALSE; | |
3021 gchar *text; | |
3022 | |
3023 DW_MUTEX_LOCK; | |
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
|
3024 #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
|
3025 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
|
3026 #else |
3 | 3027 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
|
3028 #endif |
3 | 3029 { |
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
|
3030 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 3031 |
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
|
3032 #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
|
3033 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
|
3034 { |
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
|
3035 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
|
3036 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
|
3037 |
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
|
3038 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
|
3039 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
|
3040 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
|
3041 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
|
3042 if(text) /* Should this get freed? */ |
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
|
3043 strcpy(buffer, text); |
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
|
3044 } |
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
|
3045 #else |
3 | 3046 if(tmp && GTK_IS_TEXT(tmp)) |
3047 { | |
3048 text = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), startpoint, startpoint + length); | |
3049 if(text) | |
3050 { | |
3051 strcpy(buffer, text); | |
3052 g_free(text); | |
3053 } | |
3054 } | |
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
|
3055 #endif |
3 | 3056 } |
3057 DW_MUTEX_UNLOCK; | |
3058 } | |
3059 | |
3060 /* | |
3061 * Obtains information about an MLE box. | |
3062 * Parameters: | |
3063 * handle: Handle to the MLE to be queried. | |
3064 * bytes: A pointer to a variable to return the total bytes. | |
3065 * lines: A pointer to a variable to return the number of lines. | |
3066 */ | |
3067 void dw_mle_query(HWND handle, unsigned long *bytes, unsigned long *lines) | |
3068 { | |
3069 int _locked_by_me = FALSE; | |
3070 | |
3071 if(bytes) | |
3072 *bytes = 0; | |
3073 if(lines) | |
3074 *lines = 0; | |
3075 | |
3076 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
|
3077 #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
|
3078 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
|
3079 { |
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
|
3080 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
|
3081 |
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
|
3082 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
|
3083 { |
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
|
3084 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
|
3085 |
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
|
3086 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
|
3087 *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
|
3088 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
|
3089 *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
|
3090 } |
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
|
3091 } |
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
|
3092 #else |
3 | 3093 if(GTK_IS_BOX(handle)) |
3094 { | |
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
|
3095 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 3096 |
3097 if(tmp && GTK_IS_TEXT(tmp)) | |
3098 { | |
3099 if(bytes) | |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3100 *bytes = gtk_text_get_length(GTK_TEXT(tmp)) + 1; |
3 | 3101 if(lines) |
3102 { | |
3103 gchar *text; | |
3104 | |
3105 *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
|
3106 text = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), 0, gtk_text_get_length(GTK_TEXT(tmp))); |
3 | 3107 |
3108 if(text) | |
3109 { | |
3110 int z, len = strlen(text); | |
3111 | |
3112 for(z=0;z<len;z++) | |
3113 { | |
3114 if(text[z] == '\n') | |
3115 (*lines)++; | |
3116 } | |
3117 g_free(text); | |
3118 } | |
3119 } | |
3120 } | |
3121 } | |
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
|
3122 #endif |
3 | 3123 DW_MUTEX_UNLOCK; |
3124 } | |
3125 | |
3126 /* | |
3127 * Deletes text from an MLE box. | |
3128 * Parameters: | |
3129 * handle: Handle to the MLE to be deleted from. | |
3130 * startpoint: Point to start deleting text. | |
3131 * length: Amount of text to be deleted. | |
3132 */ | |
3133 void dw_mle_delete(HWND handle, int startpoint, int length) | |
3134 { | |
3135 int _locked_by_me = FALSE; | |
3136 | |
3137 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
|
3138 #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
|
3139 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
|
3140 #else |
3 | 3141 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
|
3142 #endif |
3 | 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 |
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
|
3146 #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
|
3147 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
|
3148 { |
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
|
3149 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
|
3150 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
|
3151 |
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
|
3152 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
|
3153 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
|
3154 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
|
3155 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
|
3156 } |
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
|
3157 #else |
3 | 3158 if(tmp && GTK_IS_TEXT(tmp)) |
3159 { | |
3160 gtk_text_set_point(GTK_TEXT(tmp), startpoint); | |
3161 gtk_text_forward_delete(GTK_TEXT(tmp), length); | |
3162 } | |
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
|
3163 #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
|
3164 } |
3 | 3165 DW_MUTEX_UNLOCK; |
3166 } | |
3167 | |
3168 /* | |
3169 * Clears all text from an MLE box. | |
3170 * Parameters: | |
3171 * handle: Handle to the MLE to be cleared. | |
3172 */ | |
3173 void dw_mle_clear(HWND handle) | |
3174 { | |
3175 int length, _locked_by_me = FALSE; | |
3176 | |
3177 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
|
3178 #if GTK_MAJOR_VERSION > 1 |
122
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3179 if(GTK_IS_SCROLLED_WINDOW(handle)) |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3180 { |
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
|
3181 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
|
3182 |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3183 if(tmp && GTK_IS_TEXT_VIEW(tmp)) |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3184 { |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3185 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
|
3186 |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3187 length = -1; |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3188 gtk_text_buffer_set_text(buffer, "", length); |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3189 } |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3190 } |
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
|
3191 #else |
3 | 3192 if(GTK_IS_BOX(handle)) |
3193 { | |
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
|
3194 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 3195 |
3196 if(tmp && GTK_IS_TEXT(tmp)) | |
3197 { | |
3198 length = gtk_text_get_length(GTK_TEXT(tmp)); | |
3199 gtk_text_set_point(GTK_TEXT(tmp), 0); | |
3200 gtk_text_forward_delete(GTK_TEXT(tmp), length); | |
3201 } | |
3202 } | |
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
|
3203 #endif |
3 | 3204 DW_MUTEX_UNLOCK; |
3205 } | |
3206 | |
3207 /* | |
3208 * Sets the visible line of an MLE box. | |
3209 * Parameters: | |
3210 * handle: Handle to the MLE. | |
3211 * line: Line to be visible. | |
3212 */ | |
3213 void dw_mle_set_visible(HWND handle, int line) | |
3214 { | |
3215 int _locked_by_me = FALSE; | |
3216 | |
3217 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
|
3218 #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
|
3219 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
|
3220 { |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3221 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
|
3222 |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3223 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
|
3224 { |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3225 GtkTextBuffer *tbuffer; |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3226 GtkTextIter iter; |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3227 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
|
3228 |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3229 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
|
3230 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
|
3231 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
|
3232 if(!mark) |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3233 { |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3234 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
|
3235 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
|
3236 } |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3237 else |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3238 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
|
3239 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
|
3240 0, FALSE, 0, 0); |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3241 } |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3242 } |
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
|
3243 #else |
3 | 3244 if(GTK_IS_BOX(handle)) |
3245 { | |
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
|
3246 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 3247 |
3248 if(tmp && GTK_IS_TEXT(tmp)) | |
3249 { | |
3250 unsigned long lines; | |
3251 float pos, ratio; | |
3252 | |
3253 dw_mle_query(handle, NULL, &lines); | |
3254 | |
3255 if(lines) | |
3256 { | |
3257 ratio = (float)line/(float)lines; | |
3258 | |
3259 pos = (ratio * (float)(GTK_TEXT(tmp)->vadj->upper - GTK_TEXT(tmp)->vadj->lower)) + GTK_TEXT(tmp)->vadj->lower; | |
3260 | |
3261 gtk_adjustment_set_value(GTK_TEXT(tmp)->vadj, pos); | |
3262 } | |
3263 } | |
3264 } | |
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
|
3265 #endif |
3 | 3266 DW_MUTEX_UNLOCK; |
3267 } | |
3268 | |
3269 /* | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3270 * Sets the editablity of an MLE box. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3271 * Parameters: |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3272 * handle: Handle to the MLE. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3273 * 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
|
3274 */ |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3275 void dw_mle_set_editable(HWND handle, int state) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3276 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3277 int _locked_by_me = FALSE; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3278 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3279 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
|
3280 #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
|
3281 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
|
3282 { |
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
|
3283 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
|
3284 |
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
|
3285 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
|
3286 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
|
3287 } |
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
|
3288 #else |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3289 if(GTK_IS_BOX(handle)) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3290 { |
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
|
3291 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
|
3292 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3293 if(tmp && GTK_IS_TEXT(tmp)) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3294 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
|
3295 } |
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
|
3296 #endif |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3297 DW_MUTEX_UNLOCK; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3298 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3299 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3300 /* |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3301 * Sets the word wrap state of an MLE box. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3302 * Parameters: |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3303 * handle: Handle to the MLE. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3304 * 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
|
3305 */ |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3306 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
|
3307 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3308 int _locked_by_me = FALSE; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3309 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3310 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
|
3311 #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
|
3312 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
|
3313 { |
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
|
3314 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
|
3315 |
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
|
3316 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
|
3317 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
|
3318 } |
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
|
3319 #else |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3320 if(GTK_IS_BOX(handle)) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3321 { |
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
|
3322 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
|
3323 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3324 if(tmp && GTK_IS_TEXT(tmp)) |
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 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
|
3327 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
|
3328 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3329 } |
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
|
3330 #endif |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3331 DW_MUTEX_UNLOCK; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3332 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3333 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3334 /* |
3 | 3335 * Sets the current cursor position of an MLE box. |
3336 * Parameters: | |
3337 * handle: Handle to the MLE to be positioned. | |
3338 * point: Point to position cursor. | |
3339 */ | |
3340 void dw_mle_set(HWND handle, int point) | |
3341 { | |
3342 int _locked_by_me = FALSE; | |
3343 | |
3344 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
|
3345 #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
|
3346 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
|
3347 #else |
3 | 3348 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
|
3349 #endif |
3 | 3350 { |
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
|
3351 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 3352 |
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
|
3353 #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
|
3354 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
|
3355 { |
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
|
3356 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
|
3357 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
|
3358 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
|
3359 |
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
|
3360 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
|
3361 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
|
3362 if(!mark) |
08e56a0f9541
dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
352
diff
changeset
|
3363 { |
08e56a0f9541
dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
352
diff
changeset
|
3364 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
|
3365 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
|
3366 } |
08e56a0f9541
dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
352
diff
changeset
|
3367 else |
08e56a0f9541
dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
352
diff
changeset
|
3368 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
|
3369 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
|
3370 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
|
3371 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
|
3372 } |
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
|
3373 #else |
3 | 3374 if(tmp && GTK_IS_TEXT(tmp)) |
3375 { | |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3376 unsigned long chars; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3377 float pos, ratio; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3378 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3379 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
|
3380 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3381 if(chars) |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3382 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3383 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
|
3384 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3385 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
|
3386 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3387 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
|
3388 } |
3 | 3389 gtk_text_set_point(GTK_TEXT(tmp), point); |
3390 } | |
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
|
3391 #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
|
3392 } |
3 | 3393 DW_MUTEX_UNLOCK; |
3394 } | |
3395 | |
3396 /* | |
3397 * Finds text in an MLE box. | |
3398 * Parameters: | |
3399 * handle: Handle to the MLE to be cleared. | |
3400 * text: Text to search for. | |
3401 * point: Start point of search. | |
3402 * flags: Search specific flags. | |
3403 */ | |
3404 int dw_mle_search(HWND handle, char *text, int point, unsigned long flags) | |
3405 { | |
3406 int _locked_by_me = FALSE, retval = 0; | |
3407 | |
3408 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
|
3409 #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
|
3410 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
|
3411 #else |
3 | 3412 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
|
3413 #endif |
3 | 3414 { |
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
|
3415 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 3416 |
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
|
3417 #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
|
3418 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
|
3419 { |
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
|
3420 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
|
3421 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
|
3422 |
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
|
3423 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
|
3424 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
|
3425 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
|
3426 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
|
3427 } |
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
|
3428 #else |
3 | 3429 if(tmp && GTK_IS_TEXT(tmp)) |
3430 { | |
3431 int len = gtk_text_get_length(GTK_TEXT(tmp)); | |
3432 gchar *tmpbuf; | |
3433 | |
3434 tmpbuf = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), 0, len); | |
3435 if(tmpbuf) | |
3436 { | |
3437 int z, textlen; | |
3438 | |
3439 textlen = strlen(text); | |
3440 | |
3441 if(flags & DW_MLE_CASESENSITIVE) | |
3442 { | |
3443 for(z=point;z<(len-textlen) && !retval;z++) | |
3444 { | |
3445 if(strncmp(&tmpbuf[z], text, textlen) == 0) | |
3446 retval = z + textlen; | |
3447 } | |
3448 } | |
3449 else | |
3450 { | |
3451 for(z=point;z<(len-textlen) && !retval;z++) | |
3452 { | |
3453 if(strncasecmp(&tmpbuf[z], text, textlen) == 0) | |
3454 retval = z + textlen; | |
3455 } | |
3456 } | |
3457 | |
3458 if(retval) | |
3459 { | |
3460 gtk_text_set_point(GTK_TEXT(tmp), retval - textlen); | |
3461 gtk_editable_select_region(&(GTK_TEXT(tmp)->editable), retval - textlen, retval); | |
3462 } | |
3463 | |
3464 g_free(tmpbuf); | |
3465 } | |
3466 } | |
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
|
3467 #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
|
3468 } |
3 | 3469 DW_MUTEX_UNLOCK; |
3470 return retval; | |
3471 } | |
3472 | |
3473 /* | |
3474 * Stops redrawing of an MLE box. | |
3475 * Parameters: | |
3476 * handle: Handle to the MLE to freeze. | |
3477 */ | |
3478 void dw_mle_freeze(HWND handle) | |
3479 { | |
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
|
3480 #if GTK_MAJOR_VERSION < 2 |
3 | 3481 int _locked_by_me = FALSE; |
3482 | |
3483 DW_MUTEX_LOCK; | |
3484 if(GTK_IS_BOX(handle)) | |
3485 { | |
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
|
3486 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 3487 |
3488 if(tmp && GTK_IS_TEXT(tmp)) | |
3489 { | |
3490 gtk_text_freeze(GTK_TEXT(tmp)); | |
3491 } | |
3492 } | |
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
|
3493 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
|
3494 #endif |
3 | 3495 } |
3496 | |
3497 /* | |
3498 * Resumes redrawing of an MLE box. | |
3499 * Parameters: | |
3500 * handle: Handle to the MLE to thaw. | |
3501 */ | |
3502 void dw_mle_thaw(HWND handle) | |
3503 { | |
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
|
3504 #if GTK_MAJOR_VERSION < 2 |
3 | 3505 int _locked_by_me = FALSE; |
3506 | |
3507 DW_MUTEX_LOCK; | |
3508 if(GTK_IS_BOX(handle)) | |
3509 { | |
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
|
3510 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 3511 |
3512 if(tmp && GTK_IS_TEXT(tmp)) | |
3513 { | |
3514 gtk_text_thaw(GTK_TEXT(tmp)); | |
3515 } | |
3516 } | |
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 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
|
3518 #endif |
3 | 3519 } |
3520 | |
3521 /* | |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
3522 * Returns the range of the percent bar. |
3 | 3523 * 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
|
3524 * handle: Handle to the percent bar to be queried. |
3 | 3525 */ |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
3526 unsigned int dw_percent_query_range(HWND handle) |
3 | 3527 { |
3528 return 100; | |
3529 } | |
3530 | |
3531 /* | |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
3532 * Sets the percent bar position. |
3 | 3533 * 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
|
3534 * 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
|
3535 * position: Position of the percent bar withing the range. |
3 | 3536 */ |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
3537 void dw_percent_set_pos(HWND handle, unsigned int position) |
3 | 3538 { |
3539 int _locked_by_me = FALSE; | |
3540 | |
3541 DW_MUTEX_LOCK; | |
3542 gtk_progress_bar_update(GTK_PROGRESS_BAR(handle), (gfloat)position/100); | |
3543 DW_MUTEX_UNLOCK; | |
3544 } | |
3545 | |
3546 /* | |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3547 * 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
|
3548 * Parameters: |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3549 * 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
|
3550 */ |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3551 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
|
3552 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3553 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
|
3554 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
|
3555 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3556 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
|
3557 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
|
3558 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3559 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
|
3560 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
|
3561 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
|
3562 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3563 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
|
3564 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
|
3565 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3566 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
|
3567 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
|
3568 else |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3569 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
|
3570 } |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3571 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
|
3572 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
|
3573 } |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3574 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3575 /* |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3576 * 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
|
3577 * Parameters: |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3578 * 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
|
3579 * 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
|
3580 */ |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3581 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
|
3582 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3583 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
|
3584 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
|
3585 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3586 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
|
3587 return; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3588 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3589 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
|
3590 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
|
3591 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
|
3592 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3593 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
|
3594 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3595 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
|
3596 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
|
3597 else |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3598 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
|
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 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
|
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 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3603 /* |
195
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3604 * 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
|
3605 * Parameters: |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3606 * 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
|
3607 */ |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3608 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
|
3609 { |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3610 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
|
3611 GtkAdjustment *adjustment; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3612 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3613 if(!handle) |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3614 return 0; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3615 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3616 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
|
3617 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
|
3618 if(adjustment) |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3619 { |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3620 int max = _round_value(adjustment->upper) - 1; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3621 int thisval = _round_value(adjustment->value); |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3622 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3623 if(GTK_IS_VSCROLLBAR(handle)) |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3624 val = max - thisval; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3625 else |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3626 val = thisval; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3627 } |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3628 DW_MUTEX_UNLOCK; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3629 return val; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3630 } |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3631 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3632 /* |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3633 * 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
|
3634 * Parameters: |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3635 * 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
|
3636 * 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
|
3637 */ |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3638 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
|
3639 { |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3640 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
|
3641 GtkAdjustment *adjustment; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3642 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3643 if(!handle) |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3644 return; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3645 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3646 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
|
3647 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
|
3648 if(adjustment) |
215
03e68274623d
Two scrollbar fixes for GTK... one from Mark Hessling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
214
diff
changeset
|
3649 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
|
3650 DW_MUTEX_UNLOCK; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3651 } |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3652 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3653 /* |
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
|
3654 * 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
|
3655 * 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
|
3656 * 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
|
3657 * 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
|
3658 * 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
|
3659 */ |
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
3660 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
|
3661 { |
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
|
3662 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
|
3663 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
|
3664 |
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
|
3665 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
|
3666 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
|
3667 |
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
|
3668 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
|
3669 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
|
3670 if(adjustment) |
205
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
3671 { |
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
3672 adjustment->upper = (gdouble)range; |
216 | 3673 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
|
3674 } |
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
|
3675 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
|
3676 } |
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
|
3677 |
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
|
3678 /* |
3 | 3679 * Sets the spinbutton value. |
3680 * Parameters: | |
3681 * handle: Handle to the spinbutton to be set. | |
3682 * position: Current value of the spinbutton. | |
3683 */ | |
3684 void dw_spinbutton_set_pos(HWND handle, long position) | |
3685 { | |
3686 int _locked_by_me = FALSE; | |
3687 | |
3688 DW_MUTEX_LOCK; | |
3689 gtk_spin_button_set_value(GTK_SPIN_BUTTON(handle), (gfloat)position); | |
3690 DW_MUTEX_UNLOCK; | |
3691 } | |
3692 | |
3693 /* | |
3694 * Sets the spinbutton limits. | |
3695 * Parameters: | |
3696 * handle: Handle to the spinbutton to be set. | |
3697 * position: Current value of the spinbutton. | |
3698 * position: Current value of the spinbutton. | |
3699 */ | |
3700 void dw_spinbutton_set_limits(HWND handle, long upper, long lower) | |
3701 { | |
3702 long curval; | |
3703 GtkAdjustment *adj; | |
3704 int _locked_by_me = FALSE; | |
3705 | |
3706 curval = dw_spinbutton_query(handle); | |
3707 DW_MUTEX_LOCK; | |
3708 adj = (GtkAdjustment *)gtk_adjustment_new((gfloat)curval, (gfloat)lower, (gfloat)upper, 1.0, 5.0, 0.0); | |
3709 DW_MUTEX_UNLOCK; | |
3710 } | |
3711 | |
3712 /* | |
3713 * Sets the entryfield character limit. | |
3714 * Parameters: | |
3715 * handle: Handle to the spinbutton to be set. | |
3716 * limit: Number of characters the entryfield will take. | |
3717 */ | |
3718 void dw_entryfield_set_limit(HWND handle, ULONG limit) | |
3719 { | |
270
d2a80e648d33
Implemented dw_entryfield_set_limit() on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
269
diff
changeset
|
3720 int _locked_by_me = FALSE; |
d2a80e648d33
Implemented dw_entryfield_set_limit() on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
269
diff
changeset
|
3721 |
d2a80e648d33
Implemented dw_entryfield_set_limit() on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
269
diff
changeset
|
3722 DW_MUTEX_LOCK; |
271
38d8908c4438
Corrected incorrect typecast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
270
diff
changeset
|
3723 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
|
3724 DW_MUTEX_UNLOCK; |
3 | 3725 } |
3726 | |
3727 /* | |
3728 * Returns the current value of the spinbutton. | |
3729 * Parameters: | |
3730 * handle: Handle to the spinbutton to be queried. | |
3731 */ | |
3732 long dw_spinbutton_query(HWND handle) | |
3733 { | |
3734 long retval; | |
3735 int _locked_by_me = FALSE; | |
3736 | |
3737 DW_MUTEX_LOCK; | |
3738 retval = (long)gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(handle)); | |
3739 DW_MUTEX_UNLOCK; | |
3740 | |
3741 return retval; | |
3742 } | |
3743 | |
3744 /* | |
3745 * Returns the state of the checkbox. | |
3746 * Parameters: | |
3747 * handle: Handle to the checkbox to be queried. | |
3748 */ | |
3749 int dw_checkbox_query(HWND handle) | |
3750 { | |
3751 int retval; | |
3752 int _locked_by_me = FALSE; | |
3753 | |
3754 DW_MUTEX_LOCK; | |
3755 retval = GTK_TOGGLE_BUTTON(handle)->active; | |
3756 DW_MUTEX_UNLOCK; | |
3757 | |
3758 return retval; | |
3759 } | |
3760 | |
3761 /* | |
3762 * Sets the state of the checkbox. | |
3763 * Parameters: | |
3764 * handle: Handle to the checkbox to be queried. | |
3765 * value: TRUE for checked, FALSE for unchecked. | |
3766 */ | |
3767 void dw_checkbox_set(HWND handle, int value) | |
3768 { | |
3769 int _locked_by_me = FALSE; | |
3770 | |
3771 DW_MUTEX_LOCK; | |
3772 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(handle), value); | |
3773 DW_MUTEX_UNLOCK; | |
3774 } | |
3775 | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3776 /* |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3777 * 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
|
3778 * Parameters: |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3779 * 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
|
3780 * 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
|
3781 * title: The text title of the entry. |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3782 * icon: Handle to coresponding icon. |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3783 * parent: Parent handle or 0 if root. |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3784 * itemdata: Item specific data. |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3785 */ |
329
9b1953ed0bff
Oops missed one parameter change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
328
diff
changeset
|
3786 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
|
3787 { |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3788 #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
|
3789 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
|
3790 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
|
3791 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
|
3792 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
|
3793 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
|
3794 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
|
3795 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3796 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
|
3797 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
|
3798 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3799 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
|
3800 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
|
3801 && 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
|
3802 (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
|
3803 { |
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
|
3804 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
|
3805 |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3806 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
|
3807 |
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
|
3808 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
|
3809 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
|
3810 if(pixbuf) |
63d68387d924
Don't unref a non-existant pixmap. (GTK 2.x)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
255
diff
changeset
|
3811 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
|
3812 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
|
3813 } |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3814 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
|
3815 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3816 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
|
3817 #else |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3818 GtkWidget *newitem, *tree, *subtree, *label, *hbox, *pixmap; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3819 GdkPixmap *gdkpix; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3820 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
|
3821 int position = -1; |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3822 int _locked_by_me = FALSE; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3823 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3824 if(!handle) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3825 return NULL; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3826 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3827 DW_MUTEX_LOCK; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3828 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
|
3829 if(!tree || !GTK_IS_TREE(tree)) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3830 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3831 DW_MUTEX_UNLOCK; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3832 return NULL; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3833 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3834 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3835 if(item && GTK_IS_TREE_ITEM(item)) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3836 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
|
3837 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3838 position++; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3839 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3840 newitem = gtk_tree_item_new(); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3841 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
|
3842 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
|
3843 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
|
3844 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
|
3845 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
|
3846 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
|
3847 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
|
3848 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
|
3849 if(gdkpix) |
a167001c56df
Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
249
diff
changeset
|
3850 { |
a167001c56df
Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
249
diff
changeset
|
3851 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
|
3852 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
|
3853 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
|
3854 } |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3855 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
|
3856 gtk_widget_show(label); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3857 gtk_widget_show(hbox); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3858 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3859 if(parent) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3860 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3861 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
|
3862 if(!subtree) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3863 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
3864 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
|
3865 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
|
3866 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
|
3867 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3868 subtree = gtk_tree_new(); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3869 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3870 if(thisfunc && work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3871 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3872 gtk_signal_connect(GTK_OBJECT(subtree), "select-child", GTK_SIGNAL_FUNC(thisfunc), |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3873 (gpointer)_set_signal_handler(subtree, work.window, work.func, work.data)); |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3874 } |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3875 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
3876 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
|
3877 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
|
3878 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
|
3879 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3880 if(thisfunc && work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3881 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3882 gtk_signal_connect(GTK_OBJECT(subtree), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3883 (gpointer)_set_signal_handler(subtree, work.window, work.func, work.data)); |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3884 } |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3885 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3886 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
|
3887 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
|
3888 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
|
3889 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
|
3890 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
|
3891 gtk_widget_show(subtree); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3892 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
|
3893 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
|
3894 } |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
3895 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
|
3896 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
|
3897 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3898 else |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3899 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
3900 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
|
3901 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
|
3902 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3903 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
|
3904 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
|
3905 gtk_widget_show(newitem); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3906 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
|
3907 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
|
3908 #endif |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3909 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3910 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3911 /* |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3912 * 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
|
3913 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3914 * 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
|
3915 * 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
|
3916 * 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
|
3917 * 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
|
3918 * 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
|
3919 */ |
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
|
3920 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
|
3921 { |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3922 #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
|
3923 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
|
3924 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
|
3925 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
|
3926 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
|
3927 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
|
3928 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
|
3929 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3930 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
|
3931 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
|
3932 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3933 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
|
3934 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
|
3935 && 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
|
3936 (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
|
3937 { |
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
|
3938 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
|
3939 |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3940 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
|
3941 |
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
|
3942 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
|
3943 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
|
3944 if(pixbuf) |
63d68387d924
Don't unref a non-existant pixmap. (GTK 2.x)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
255
diff
changeset
|
3945 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
|
3946 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
|
3947 } |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3948 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
|
3949 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3950 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
|
3951 #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
|
3952 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
|
3953 GdkPixmap *gdkpix; |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3954 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
|
3955 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
|
3956 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3957 if(!handle) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3958 return NULL; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3959 |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3960 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
|
3961 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
|
3962 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
|
3963 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3964 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
|
3965 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
|
3966 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3967 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
|
3968 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
|
3969 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
|
3970 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
|
3971 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
|
3972 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
|
3973 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
|
3974 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
|
3975 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
|
3976 if(gdkpix) |
a167001c56df
Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
249
diff
changeset
|
3977 { |
a167001c56df
Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
249
diff
changeset
|
3978 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
|
3979 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
|
3980 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
|
3981 } |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3982 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
|
3983 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
|
3984 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
|
3985 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3986 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
|
3987 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3988 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
|
3989 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
|
3990 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
3991 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
|
3992 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
|
3993 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
|
3994 |
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 subtree = gtk_tree_new(); |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3996 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3997 if(thisfunc && work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3998 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3999 gtk_signal_connect(GTK_OBJECT(subtree), "select-child", GTK_SIGNAL_FUNC(thisfunc), |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
4000 (gpointer)_set_signal_handler(subtree, work.window, work.func, work.data)); |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
4001 } |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4002 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4003 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
|
4004 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
|
4005 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
|
4006 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
4007 if(thisfunc && work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
4008 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
4009 gtk_signal_connect(GTK_OBJECT(subtree), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
4010 (gpointer)_set_signal_handler(subtree, work.window, work.func, work.data)); |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
4011 } |
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
|
4012 |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4013 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
|
4014 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
|
4015 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
|
4016 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
|
4017 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
|
4018 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
|
4019 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
|
4020 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
|
4021 } |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4022 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
|
4023 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
|
4024 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4025 else |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4026 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4027 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
|
4028 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
|
4029 } |
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
|
4030 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
|
4031 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
|
4032 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
|
4033 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
|
4034 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
|
4035 #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
|
4036 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4037 |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4038 /* |
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
|
4039 * 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
|
4040 * 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
|
4041 * 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
|
4042 * 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
|
4043 * 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
|
4044 * 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
|
4045 */ |
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
|
4046 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
|
4047 { |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4048 #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
|
4049 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
|
4050 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
|
4051 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
|
4052 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
|
4053 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4054 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
|
4055 return; |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4056 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4057 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
|
4058 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
|
4059 && 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
|
4060 (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
|
4061 { |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4062 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
|
4063 |
139
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4064 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
|
4065 if(pixbuf) |
63d68387d924
Don't unref a non-existant pixmap. (GTK 2.x)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
255
diff
changeset
|
4066 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
|
4067 } |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4068 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
|
4069 #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
|
4070 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
|
4071 GdkPixmap *gdkpix; |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4072 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
|
4073 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
|
4074 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
|
4075 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4076 if(!handle || !item) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4077 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4078 |
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
|
4079 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
|
4080 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
|
4081 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
|
4082 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
|
4083 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
|
4084 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
|
4085 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
|
4086 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
|
4087 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
|
4088 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
|
4089 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
|
4090 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
|
4091 if(gdkpix) |
a167001c56df
Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
249
diff
changeset
|
4092 { |
a167001c56df
Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
249
diff
changeset
|
4093 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
|
4094 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
|
4095 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
|
4096 } |
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
|
4097 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
|
4098 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
|
4099 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
|
4100 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
|
4101 #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
|
4102 } |
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
|
4103 |
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
|
4104 /* |
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
|
4105 * 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
|
4106 * 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
|
4107 * 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
|
4108 * 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
|
4109 * 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
|
4110 */ |
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
|
4111 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
|
4112 { |
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
|
4113 #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
|
4114 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
|
4115 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
|
4116 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
|
4117 |
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
|
4118 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
|
4119 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
|
4120 |
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
|
4121 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
|
4122 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
|
4123 && 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
|
4124 (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
|
4125 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
|
4126 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
|
4127 #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
|
4128 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
|
4129 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4130 if(!handle || !item) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4131 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4132 |
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
|
4133 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
|
4134 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
|
4135 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
|
4136 #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
|
4137 } |
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
|
4138 |
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
|
4139 /* |
317
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4140 * 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
|
4141 * Parameters: |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4142 * 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
|
4143 * 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
|
4144 */ |
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
|
4145 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
|
4146 { |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4147 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
|
4148 #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
|
4149 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
|
4150 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
|
4151 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
|
4152 |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4153 if(!handle || !item) |
319
aed5d742896d
Fixed errant returns on failure.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
317
diff
changeset
|
4154 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
|
4155 |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4156 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
|
4157 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
|
4158 && 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
|
4159 (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
|
4160 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
|
4161 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
|
4162 #else |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4163 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
|
4164 |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4165 if(!handle || !item) |
319
aed5d742896d
Fixed errant returns on failure.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
317
diff
changeset
|
4166 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
|
4167 |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4168 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
|
4169 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
|
4170 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
|
4171 #endif |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4172 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
|
4173 } |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4174 |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4175 /* |
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
|
4176 * 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
|
4177 * 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
|
4178 * 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
|
4179 * 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
|
4180 */ |
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
|
4181 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
|
4182 { |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4183 #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
|
4184 GtkWidget *tree; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4185 GtkTreeStore *store; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4186 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
|
4187 |
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
|
4188 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
|
4189 return; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4190 |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4191 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
|
4192 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
|
4193 && 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
|
4194 (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
|
4195 { |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4196 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
|
4197 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
|
4198 |
139
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4199 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
|
4200 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
|
4201 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
|
4202 } |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4203 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
|
4204 #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
|
4205 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
|
4206 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
|
4207 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4208 if(!handle || !item) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4209 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4210 |
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
|
4211 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
|
4212 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
|
4213 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
|
4214 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
|
4215 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
|
4216 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
|
4217 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
|
4218 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
|
4219 #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
|
4220 } |
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 |
143
1d57c27e4adc
Moved _dw_recursive_free into GTK 2.0 #ifdefs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
142
diff
changeset
|
4222 #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
|
4223 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
|
4224 { |
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
|
4225 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
|
4226 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
|
4227 |
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
|
4228 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
|
4229 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
|
4230 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
|
4231 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
|
4232 |
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(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
|
4234 { |
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
|
4235 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
|
4236 _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
|
4237 } 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
|
4238 } |
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
|
4239 } |
143
1d57c27e4adc
Moved _dw_recursive_free into GTK 2.0 #ifdefs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
142
diff
changeset
|
4240 #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
|
4241 |
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
|
4242 /* |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4243 * Removes all nodes from a tree. |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4244 * Parameters: |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4245 * 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
|
4246 */ |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4247 void dw_tree_clear(HWND handle) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4248 { |
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 #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
|
4250 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
|
4251 GtkTreeStore *store; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4252 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
|
4253 |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4254 if(!handle) |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4255 return; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4256 |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4257 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
|
4258 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
|
4259 && 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
|
4260 (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
|
4261 { |
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
|
4262 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
|
4263 |
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
|
4264 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
|
4265 { |
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
|
4266 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
|
4267 _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
|
4268 } 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
|
4269 } |
139
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4270 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
|
4271 } |
139
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4272 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
|
4273 #else |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4274 GtkWidget *tree; |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4275 int _locked_by_me = FALSE; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4276 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4277 if(!handle) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4278 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4279 |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4280 DW_MUTEX_LOCK; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4281 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
|
4282 if(!tree || !GTK_IS_TREE(tree)) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4283 { |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4284 DW_MUTEX_UNLOCK; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4285 return; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4286 } |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4287 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
|
4288 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
|
4289 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
|
4290 #endif |
30
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 |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4293 /* |
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
|
4294 * 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
|
4295 * 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
|
4296 * 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
|
4297 * 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
|
4298 */ |
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
|
4299 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
|
4300 { |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4301 #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
|
4302 GtkWidget *tree; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4303 GtkTreeStore *store; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4304 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
|
4305 |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4306 if(!handle) |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4307 return; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4308 |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4309 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
|
4310 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
|
4311 && 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
|
4312 (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
|
4313 { |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4314 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
|
4315 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
|
4316 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
|
4317 } |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4318 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
|
4319 #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
|
4320 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
|
4321 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4322 if(!handle || !item) |
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 |
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
|
4325 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
|
4326 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
|
4327 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
|
4328 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
|
4329 #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
|
4330 } |
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
|
4331 |
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
|
4332 /* |
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
|
4333 * 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
|
4334 * 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
|
4335 * 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
|
4336 * 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
|
4337 */ |
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
|
4338 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
|
4339 { |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4340 #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
|
4341 GtkWidget *tree; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4342 GtkTreeStore *store; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4343 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
|
4344 |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4345 if(!handle) |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4346 return; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4347 |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4348 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
|
4349 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
|
4350 && 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
|
4351 (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
|
4352 { |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4353 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
|
4354 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
|
4355 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
|
4356 } |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4357 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
|
4358 #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
|
4359 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
|
4360 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4361 if(!handle || !item) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4362 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4363 |
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
|
4364 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
|
4365 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
|
4366 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
|
4367 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
|
4368 #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
|
4369 } |
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 |
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 /* |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4372 * Removes a node from a tree. |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4373 * Parameters: |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4374 * 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
|
4375 * item: Handle to node to be deleted. |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4376 */ |
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
|
4377 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
|
4378 { |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4379 #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
|
4380 GtkWidget *tree; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4381 GtkTreeStore *store; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4382 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
|
4383 |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4384 if(!handle) |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4385 return; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4386 |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4387 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
|
4388 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
|
4389 && 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
|
4390 (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
|
4391 { |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4392 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
|
4393 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
|
4394 } |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4395 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
|
4396 #else |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4397 GtkWidget *tree, *lastselect, *parenttree; |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4398 int _locked_by_me = FALSE; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4399 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4400 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
|
4401 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4402 |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4403 DW_MUTEX_LOCK; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4404 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
|
4405 if(!tree || !GTK_IS_TREE(tree)) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4406 { |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4407 DW_MUTEX_UNLOCK; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4408 return; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4409 } |
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
|
4410 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4411 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
|
4412 |
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4413 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
|
4414 |
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
|
4415 if(lastselect == item) |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4416 { |
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
|
4417 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
|
4418 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
|
4419 } |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4420 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4421 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
|
4422 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
|
4423 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
|
4424 #endif |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4425 } |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4426 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4427 static int _dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator, int extra) |
3 | 4428 { |
4429 GtkWidget *clist; | |
4430 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
|
4431 int z, multi; |
3 | 4432 int _locked_by_me = FALSE; |
355
3a71623fc219
Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
354
diff
changeset
|
4433 GtkJustification justification; |
3 | 4434 |
4435 DW_MUTEX_LOCK; | |
4436 clist = gtk_clist_new_with_titles(count, (gchar **)titles); | |
4437 if(!clist) | |
4438 { | |
4439 DW_MUTEX_UNLOCK; | |
4440 return FALSE; | |
4441 } | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4442 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
|
4443 gtk_object_set_data(GTK_OBJECT(handle), "_dw_multi", (gpointer)multi); |
3 | 4444 |
4445 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
|
4446 if(multi) |
2216e65ad2ae
Removed slider flags and container selection flags from the header file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
346
diff
changeset
|
4447 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
|
4448 else |
2216e65ad2ae
Removed slider flags and container selection flags from the header file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
346
diff
changeset
|
4449 gtk_clist_set_selection_mode(GTK_CLIST(clist), GTK_SELECTION_SINGLE); |
3 | 4450 gtk_container_add(GTK_CONTAINER(handle), clist); |
4451 gtk_object_set_user_data(GTK_OBJECT(handle), (gpointer)clist); | |
4452 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
|
4453 gtk_object_set_data(GTK_OBJECT(clist), "_dw_colcount", (gpointer)count); |
3 | 4454 |
4455 if(extra) | |
4456 gtk_clist_set_column_width(GTK_CLIST(clist), 1, 120); | |
4457 | |
4458 for(z=0;z<count;z++) | |
4459 { | |
4460 if(!extra || z > 1) | |
4461 gtk_clist_set_column_width(GTK_CLIST(clist), z, 50); | |
4462 sprintf(numbuf, "%d", z); | |
4463 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
|
4464 if(flags[z]&DW_CFA_RIGHT) |
3a71623fc219
Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
354
diff
changeset
|
4465 justification = GTK_JUSTIFY_RIGHT; |
3a71623fc219
Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
354
diff
changeset
|
4466 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
|
4467 justification = GTK_JUSTIFY_CENTER; |
3a71623fc219
Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
354
diff
changeset
|
4468 else |
3a71623fc219
Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
354
diff
changeset
|
4469 justification = GTK_JUSTIFY_LEFT; |
3a71623fc219
Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
354
diff
changeset
|
4470 gtk_clist_set_column_justification(GTK_CLIST(clist),z,justification); |
3 | 4471 } |
4472 | |
4473 DW_MUTEX_UNLOCK; | |
4474 return TRUE; | |
4475 } | |
4476 | |
4477 /* | |
4478 * Sets up the container columns. | |
4479 * Parameters: | |
4480 * handle: Handle to the container to be configured. | |
4481 * flags: An array of unsigned longs with column flags. | |
4482 * titles: An array of strings with column text titles. | |
4483 * count: The number of columns (this should match the arrays). | |
4484 * separator: The column number that contains the main separator. | |
4485 * (this item may only be used in OS/2) | |
4486 */ | |
4487 int dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator) | |
4488 { | |
4489 return _dw_container_setup(handle, flags, titles, count, separator, 0); | |
4490 } | |
4491 | |
4492 /* | |
4493 * Sets up the filesystem columns, note: filesystem always has an icon/filename field. | |
4494 * Parameters: | |
4495 * handle: Handle to the container to be configured. | |
4496 * flags: An array of unsigned longs with column flags. | |
4497 * titles: An array of strings with column text titles. | |
4498 * count: The number of columns (this should match the arrays). | |
4499 */ | |
4500 int dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count) | |
4501 { | |
4502 char **newtitles = malloc(sizeof(char *) * (count + 2)); | |
4503 unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 2)); | |
4504 | |
4505 newtitles[0] = "Icon"; | |
4506 newtitles[1] = "Filename"; | |
4507 | |
4508 newflags[0] = DW_CFA_BITMAPORICON | DW_CFA_CENTER | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR; | |
4509 newflags[1] = DW_CFA_STRING | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR; | |
4510 | |
4511 memcpy(&newtitles[2], titles, sizeof(char *) * count); | |
4512 memcpy(&newflags[2], flags, sizeof(unsigned long) * count); | |
4513 | |
4514 _dw_container_setup(handle, newflags, newtitles, count + 2, 2, 1); | |
4515 | |
4516 free(newtitles); | |
4517 free(newflags); | |
4518 return TRUE; | |
4519 } | |
4520 | |
4521 /* | |
4522 * Obtains an icon from a module (or header in GTK). | |
4523 * Parameters: | |
4524 * module: Handle to module (DLL) in OS/2 and Windows. | |
4525 * id: A unsigned long id int the resources on OS/2 and | |
4526 * Windows, on GTK this is converted to a pointer | |
4527 * to an embedded XPM. | |
4528 */ | |
4529 unsigned long dw_icon_load(unsigned long module, unsigned long id) | |
4530 { | |
4531 return id; | |
4532 } | |
4533 | |
4534 /* | |
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
|
4535 * 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
|
4536 * 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
|
4537 * 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
|
4538 * 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
|
4539 * (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
|
4540 */ |
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
|
4541 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
|
4542 { |
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
|
4543 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
|
4544 #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
|
4545 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
|
4546 #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
|
4547 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
|
4548 #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
|
4549 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
|
4550 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
|
4551 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4552 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
|
4553 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
|
4554 |
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
|
4555 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
|
4556 |
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
|
4557 /* 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
|
4558 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
|
4559 { |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4560 /* 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
|
4561 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
|
4562 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
|
4563 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
|
4564 } |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4565 |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4566 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
|
4567 /* 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
|
4568 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
|
4569 { |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4570 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
|
4571 { |
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
|
4572 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
|
4573 break; |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4574 } |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4575 } |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4576 |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4577 /* 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
|
4578 * array. |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4579 */ |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4580 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
|
4581 { |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4582 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
|
4583 |
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
|
4584 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
|
4585 _PixmapCount++; |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4586 |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4587 _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
|
4588 |
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(found) |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4590 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
|
4591 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
|
4592 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
|
4593 _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
|
4594 _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
|
4595 } |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4596 |
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 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
|
4598 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
|
4599 |
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
|
4600 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
|
4601 { |
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
|
4602 _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
|
4603 _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
|
4604 _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
|
4605 |
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
|
4606 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
|
4607 } |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4608 #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
|
4609 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
|
4610 |
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
|
4611 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
|
4612 { |
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
|
4613 _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
|
4614 _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
|
4615 |
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
|
4616 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
|
4617 _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
|
4618 _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
|
4619 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
|
4620 } |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4621 #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
|
4622 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
|
4623 _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
|
4624 #endif |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4625 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
|
4626 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
|
4627 { |
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
|
4628 _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
|
4629 _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
|
4630 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
|
4631 } |
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
|
4632 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
|
4633 } |
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
|
4634 |
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
|
4635 /* |
3 | 4636 * Frees a loaded resource in OS/2 and Windows. |
4637 * Parameters: | |
4638 * handle: Handle to icon returned by dw_icon_load(). | |
4639 */ | |
4640 void dw_icon_free(unsigned long handle) | |
4641 { | |
258
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 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
|
4643 * 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
|
4644 * 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
|
4645 */ |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4646 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
|
4647 { |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4648 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
|
4649 |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4650 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
|
4651 { |
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
|
4652 #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
|
4653 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
|
4654 { |
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
|
4655 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
|
4656 _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
|
4657 } |
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
|
4658 #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
|
4659 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
|
4660 { |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4661 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
|
4662 _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
|
4663 } |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4664 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
|
4665 { |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4666 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
|
4667 _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
|
4668 } |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4669 _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
|
4670 } |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4671 } |
3 | 4672 } |
4673 | |
72
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
4674 /* 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
|
4675 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
|
4676 { |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
4677 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
|
4678 } |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
4679 |
3 | 4680 /* |
4681 * Allocates memory used to populate a container. | |
4682 * Parameters: | |
4683 * handle: Handle to the container window (widget). | |
4684 * rowcount: The number of items to be populated. | |
4685 */ | |
4686 void *dw_container_alloc(HWND handle, int rowcount) | |
4687 { | |
4688 int z, count = 0; | |
4689 GtkWidget *clist; | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
4690 GdkColor *fore, *back; |
3 | 4691 char **blah; |
4692 int _locked_by_me = FALSE; | |
4693 | |
4694 DW_MUTEX_LOCK; | |
4695 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
4696 if(!clist) | |
4697 { | |
4698 DW_MUTEX_UNLOCK; | |
4699 return NULL; | |
4700 } | |
4701 | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4702 count = (int)gtk_object_get_data(GTK_OBJECT(clist), "_dw_colcount"); |
3 | 4703 |
4704 if(!count) | |
4705 { | |
4706 DW_MUTEX_UNLOCK; | |
4707 return NULL; | |
4708 } | |
4709 | |
4710 blah = malloc(sizeof(char *) * count); | |
4711 memset(blah, 0, sizeof(char *) * count); | |
4712 | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4713 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
|
4714 back = (GdkColor *)gtk_object_get_data(GTK_OBJECT(clist), "_dw_backgdk"); |
3 | 4715 gtk_clist_freeze(GTK_CLIST(clist)); |
4716 for(z=0;z<rowcount;z++) | |
4717 { | |
4718 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
|
4719 if(fore) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
4720 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
|
4721 if(back) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
4722 gtk_clist_set_background(GTK_CLIST(clist), z, back); |
3 | 4723 } |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4724 gtk_object_set_data(GTK_OBJECT(clist), "_dw_rowcount", (gpointer)rowcount); |
3 | 4725 free(blah); |
4726 DW_MUTEX_UNLOCK; | |
4727 return (void *)handle; | |
4728 } | |
4729 | |
4730 /* | |
4731 * Sets an item in specified row and column to the given data. | |
4732 * Parameters: | |
4733 * handle: Handle to the container window (widget). | |
4734 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
4735 * column: Zero based column of data being set. | |
4736 * row: Zero based row of data being set. | |
4737 * data: Pointer to the data to be added. | |
4738 */ | |
4739 void dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data) | |
4740 { | |
4741 char numbuf[10], textbuffer[100]; | |
4742 int flag = 0; | |
4743 GtkWidget *clist; | |
4744 int _locked_by_me = FALSE; | |
4745 | |
4746 DW_MUTEX_LOCK; | |
4747 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
4748 if(!clist) | |
4749 { | |
4750 DW_MUTEX_UNLOCK; | |
4751 return; | |
4752 } | |
4753 | |
4754 sprintf(numbuf, "%d", column); | |
4755 flag = (int)gtk_object_get_data(GTK_OBJECT(clist), numbuf); | |
4756 | |
4757 if(flag & DW_CFA_BITMAPORICON) | |
4758 { | |
4759 long hicon = *((long *)data); | |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4760 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
|
4761 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
|
4762 |
3 | 4763 if(pixmap) |
4764 gtk_clist_set_pixmap(GTK_CLIST(clist), row, column, pixmap, bitmap); | |
4765 } | |
4766 else if(flag & DW_CFA_STRING) | |
4767 { | |
4768 char *tmp = *((char **)data); | |
4769 gtk_clist_set_text(GTK_CLIST(clist), row, column, tmp); | |
4770 } | |
4771 else if(flag & DW_CFA_ULONG) | |
4772 { | |
4773 ULONG tmp = *((ULONG *)data); | |
4774 | |
4775 sprintf(textbuffer, "%lu", tmp); | |
4776 | |
4777 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer); | |
4778 } | |
4779 else if(flag & DW_CFA_DATE) | |
4780 { | |
165
d03716228b7f
Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
164
diff
changeset
|
4781 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
|
4782 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
|
4783 |
d03716228b7f
Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
164
diff
changeset
|
4784 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
|
4785 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
|
4786 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
|
4787 |
d03716228b7f
Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
164
diff
changeset
|
4788 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
|
4789 |
3 | 4790 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer); |
4791 } | |
4792 else if(flag & DW_CFA_TIME) | |
4793 { | |
165
d03716228b7f
Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
164
diff
changeset
|
4794 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
|
4795 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
|
4796 |
d03716228b7f
Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
164
diff
changeset
|
4797 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
|
4798 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
|
4799 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
|
4800 |
d03716228b7f
Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
164
diff
changeset
|
4801 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
|
4802 |
3 | 4803 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer); |
4804 } | |
4805 DW_MUTEX_UNLOCK; | |
4806 } | |
4807 | |
4808 /* | |
167
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
4809 * 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
|
4810 * Parameters: |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
4811 * 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
|
4812 * 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
|
4813 * 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
|
4814 * 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
|
4815 */ |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
4816 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
|
4817 { |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
4818 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
|
4819 } |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
4820 |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
4821 /* |
3 | 4822 * Sets an item in specified row and column to the given data. |
4823 * Parameters: | |
4824 * handle: Handle to the container window (widget). | |
4825 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
4826 * column: Zero based column of data being set. | |
4827 * row: Zero based row of data being set. | |
4828 * data: Pointer to the data to be added. | |
4829 */ | |
4830 void dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, unsigned long icon) | |
4831 { | |
4832 dw_container_set_item(handle, pointer, 0, row, (void *)&icon); | |
4833 dw_container_set_item(handle, pointer, 1, row, (void *)&filename); | |
4834 } | |
4835 | |
4836 /* | |
4837 * Sets an item in specified row and column to the given data. | |
4838 * Parameters: | |
4839 * handle: Handle to the container window (widget). | |
4840 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
4841 * column: Zero based column of data being set. | |
4842 * row: Zero based row of data being set. | |
4843 * data: Pointer to the data to be added. | |
4844 */ | |
4845 void dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data) | |
4846 { | |
4847 dw_container_set_item(handle, pointer, column + 2, row, data); | |
4848 } | |
4849 | |
4850 /* | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4851 * 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
|
4852 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4853 * 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
|
4854 * 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
|
4855 * 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
|
4856 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4857 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
|
4858 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4859 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
|
4860 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
|
4861 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4862 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
|
4863 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
|
4864 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4865 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
|
4866 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
|
4867 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
|
4868 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4869 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4870 /* |
3 | 4871 * Sets the title of a row in the container. |
4872 * Parameters: | |
4873 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
4874 * row: Zero based row of data being set. | |
4875 * title: String title of the item. | |
4876 */ | |
4877 void dw_container_set_row_title(void *pointer, int row, char *title) | |
4878 { | |
4879 GtkWidget *clist; | |
4880 int _locked_by_me = FALSE; | |
4881 | |
4882 DW_MUTEX_LOCK; | |
4883 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(pointer)); | |
4884 | |
4885 if(clist) | |
4886 gtk_clist_set_row_data(GTK_CLIST(clist), row, (gpointer)title); | |
4887 DW_MUTEX_UNLOCK; | |
4888 } | |
4889 | |
4890 /* | |
4891 * Sets the title of a row in the container. | |
4892 * Parameters: | |
4893 * handle: Handle to the container window (widget). | |
4894 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
4895 * rowcount: The number of rows to be inserted. | |
4896 */ | |
4897 void dw_container_insert(HWND handle, void *pointer, int rowcount) | |
4898 { | |
4899 GtkWidget *clist; | |
4900 int _locked_by_me = FALSE; | |
4901 | |
4902 DW_MUTEX_LOCK; | |
4903 clist = gtk_object_get_user_data(GTK_OBJECT(handle)); | |
4904 | |
4905 if(clist && GTK_IS_CLIST(clist)) | |
4906 gtk_clist_thaw(GTK_CLIST(clist)); | |
4907 DW_MUTEX_UNLOCK; | |
4908 } | |
4909 | |
4910 /* | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4911 * 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
|
4912 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4913 * 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
|
4914 * 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
|
4915 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4916 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
|
4917 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4918 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
|
4919 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
|
4920 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4921 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
|
4922 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
|
4923 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
|
4924 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4925 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
|
4926 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4927 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
|
4928 |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
4929 _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
|
4930 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4931 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
|
4932 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
|
4933 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4934 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
|
4935 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
|
4936 else |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4937 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
|
4938 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4939 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
|
4940 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4941 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
|
4942 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4943 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4944 /* |
3 | 4945 * Removes all rows from a container. |
4946 * Parameters: | |
4947 * 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
|
4948 * redraw: TRUE to cause the container to redraw immediately. |
3 | 4949 */ |
52
0804483f6320
Added a redraw parameter to dw_container_clear().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
51
diff
changeset
|
4950 void dw_container_clear(HWND handle, int redraw) |
3 | 4951 { |
4952 GtkWidget *clist; | |
4953 int _locked_by_me = FALSE; | |
4954 | |
4955 DW_MUTEX_LOCK; | |
4956 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
4957 if(clist && GTK_IS_CLIST(clist)) | |
4958 { | |
72
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
4959 _dw_unselect(clist); |
3 | 4960 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
|
4961 gtk_object_set_data(GTK_OBJECT(clist), "_dw_rowcount", (gpointer)0); |
3 | 4962 } |
4963 DW_MUTEX_UNLOCK; | |
4964 } | |
4965 | |
4966 /* | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4967 * 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
|
4968 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4969 * 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
|
4970 * 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
|
4971 * 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
|
4972 * 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
|
4973 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4974 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
|
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 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
|
4977 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
|
4978 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
|
4979 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4980 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
|
4981 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
|
4982 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
|
4983 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4984 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
|
4985 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
|
4986 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4987 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
|
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 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
|
4990 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
|
4991 break; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4992 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
|
4993 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
|
4994 break; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4995 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4996 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
|
4997 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4998 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4999 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
|
5000 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5001 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5002 /* |
3 | 5003 * Starts a new query of a container. |
5004 * Parameters: | |
5005 * handle: Handle to the window (widget) to be queried. | |
5006 * flags: If this parameter is DW_CRA_SELECTED it will only | |
5007 * return items that are currently selected. Otherwise | |
5008 * it will return all records in the container. | |
5009 */ | |
5010 char *dw_container_query_start(HWND handle, unsigned long flags) | |
5011 { | |
5012 GtkWidget *clist; | |
5013 GList *list; | |
5014 char *retval = NULL; | |
5015 int _locked_by_me = FALSE; | |
5016 | |
5017 DW_MUTEX_LOCK; | |
5018 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
5019 | |
5020 if(!clist) | |
5021 { | |
5022 DW_MUTEX_UNLOCK; | |
5023 return NULL; | |
5024 } | |
5025 | |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5026 /* 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
|
5027 if(flags & DW_CRA_SELECTED) |
3 | 5028 { |
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
|
5029 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
|
5030 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5031 if(list) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5032 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5033 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
|
5034 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
|
5035 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5036 } |
364
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
5037 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
|
5038 { |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
5039 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
|
5040 } |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5041 else |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5042 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5043 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
|
5044 gtk_object_set_data(GTK_OBJECT(clist), "_dw_querypos", (gpointer)1); |
3 | 5045 } |
5046 DW_MUTEX_UNLOCK; | |
5047 return retval; | |
5048 } | |
5049 | |
5050 /* | |
5051 * Continues an existing query of a container. | |
5052 * Parameters: | |
5053 * handle: Handle to the window (widget) to be queried. | |
5054 * flags: If this parameter is DW_CRA_SELECTED it will only | |
5055 * return items that are currently selected. Otherwise | |
5056 * it will return all records in the container. | |
5057 */ | |
5058 char *dw_container_query_next(HWND handle, unsigned long flags) | |
5059 { | |
5060 GtkWidget *clist; | |
5061 GList *list; | |
5062 char *retval = NULL; | |
5063 int _locked_by_me = FALSE; | |
5064 | |
5065 DW_MUTEX_LOCK; | |
5066 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
5067 | |
5068 if(!clist) | |
5069 { | |
5070 DW_MUTEX_UNLOCK; | |
5071 return NULL; | |
5072 } | |
5073 | |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5074 /* 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
|
5075 if(flags & DW_CRA_SELECTED) |
3 | 5076 { |
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
|
5077 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
|
5078 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5079 if(list) |
3 | 5080 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5081 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
|
5082 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
|
5083 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5084 while(list && counter < pos) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5085 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5086 list = list->next; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5087 counter++; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5088 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5089 |
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
|
5090 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
|
5091 retval = (char *)gtk_clist_get_row_data(GTK_CLIST(clist), GPOINTER_TO_UINT(list->data)); |
3 | 5092 } |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5093 } |
364
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
5094 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
|
5095 { |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
5096 /* 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
|
5097 * 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
|
5098 */ |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
5099 retval = NULL; |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
5100 } |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5101 else |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5102 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5103 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
|
5104 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5105 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
|
5106 gtk_object_set_data(GTK_OBJECT(clist), "_dw_querypos", (gpointer)pos+1); |
3 | 5107 } |
5108 DW_MUTEX_UNLOCK; | |
5109 return retval; | |
5110 } | |
5111 | |
5112 /* | |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5113 * 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
|
5114 * Parameters: |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5115 * 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
|
5116 * 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
|
5117 */ |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5118 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
|
5119 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5120 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
|
5121 GtkWidget *clist; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5122 int rowcount, z; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5123 char *rowdata; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5124 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5125 DW_MUTEX_LOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5126 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
|
5127 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5128 if(!clist) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5129 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5130 DW_MUTEX_UNLOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5131 return; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5132 } |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5133 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
|
5134 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5135 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
|
5136 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5137 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
|
5138 if(rowdata == text) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5139 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5140 gfloat pos; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5141 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
|
5142 |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
5143 _dw_unselect(clist); |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
5144 |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5145 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
|
5146 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5147 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
|
5148 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
|
5149 DW_MUTEX_UNLOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5150 return; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5151 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5152 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5153 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5154 DW_MUTEX_UNLOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5155 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5156 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5157 /* |
167
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5158 * 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
|
5159 * Parameters: |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5160 * 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
|
5161 * 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
|
5162 */ |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5163 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
|
5164 { |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5165 int _locked_by_me = FALSE; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5166 GtkWidget *clist; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5167 int rowcount, z; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5168 char *rowdata; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5169 |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5170 DW_MUTEX_LOCK; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5171 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
|
5172 |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5173 if(!clist) |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5174 { |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5175 DW_MUTEX_UNLOCK; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5176 return; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
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"); |
167
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5179 |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5180 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
|
5181 { |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5182 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
|
5183 if(rowdata == text) |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5184 { |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5185 _dw_unselect(clist); |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5186 |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5187 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
|
5188 |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5189 rowcount--; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5190 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5191 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
|
5192 DW_MUTEX_UNLOCK; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5193 return; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5194 } |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5195 } |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5196 |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5197 DW_MUTEX_UNLOCK; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5198 } |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5199 |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5200 /* |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5201 * 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
|
5202 * Parameters: |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5203 * 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
|
5204 */ |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5205 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
|
5206 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5207 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
|
5208 GtkWidget *clist; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5209 int colcount, z; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5210 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5211 DW_MUTEX_LOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5212 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
|
5213 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5214 if(!clist) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5215 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5216 DW_MUTEX_UNLOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5217 return; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5218 } |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5219 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
|
5220 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
|
5221 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5222 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
|
5223 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
|
5224 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5225 DW_MUTEX_UNLOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5226 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5227 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5228 /* |
3 | 5229 * Creates a rendering context widget (window) to be packed. |
5230 * Parameters: | |
5231 * id: An id to be used with dw_window_from_id. | |
5232 * Returns: | |
5233 * A handle to the widget or NULL on failure. | |
5234 */ | |
5235 HWND dw_render_new(unsigned long id) | |
5236 { | |
5237 int _locked_by_me = FALSE; | |
5238 GtkWidget *tmp; | |
5239 | |
5240 DW_MUTEX_LOCK; | |
5241 tmp = gtk_drawing_area_new(); | |
5242 gtk_widget_set_events(tmp, GDK_EXPOSURE_MASK | |
5243 | GDK_LEAVE_NOTIFY_MASK | |
5244 | 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
|
5245 | GDK_KEY_PRESS_MASK |
3 | 5246 | GDK_POINTER_MOTION_MASK |
5247 | 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
|
5248 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
|
5249 GTK_WIDGET_SET_FLAGS(tmp, GTK_CAN_FOCUS); |
3 | 5250 gtk_widget_show(tmp); |
5251 DW_MUTEX_UNLOCK; | |
5252 return tmp; | |
5253 } | |
5254 | |
193
efd4703450fa
Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
185
diff
changeset
|
5255 /* 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
|
5256 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
|
5257 { |
efd4703450fa
Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
185
diff
changeset
|
5258 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
|
5259 { |
efd4703450fa
Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
185
diff
changeset
|
5260 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
|
5261 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
|
5262 } |
372
3ef2cf70ee07
Code for drawing text with a background color on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
369
diff
changeset
|
5263 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
|
5264 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
|
5265 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
|
5266 } |
efd4703450fa
Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
185
diff
changeset
|
5267 |
3 | 5268 /* Sets the current foreground drawing color. |
5269 * Parameters: | |
5270 * red: red value. | |
5271 * green: green value. | |
5272 * blue: blue value. | |
5273 */ | |
5274 void dw_color_foreground_set(unsigned long value) | |
5275 { | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5276 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
|
5277 GdkColor color = _internal_color(value); |
3 | 5278 |
5279 DW_MUTEX_LOCK; | |
373
d04b0699fc28
Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
372
diff
changeset
|
5280 gdk_color_alloc(_dw_cmap, &color); |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5281 _foreground[index] = color; |
3 | 5282 DW_MUTEX_UNLOCK; |
5283 } | |
5284 | |
5285 /* Sets the current background drawing color. | |
5286 * Parameters: | |
5287 * red: red value. | |
5288 * green: green value. | |
5289 * blue: blue value. | |
5290 */ | |
5291 void dw_color_background_set(unsigned long value) | |
5292 { | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5293 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
|
5294 GdkColor color = _internal_color(value); |
3 | 5295 |
5296 DW_MUTEX_LOCK; | |
373
d04b0699fc28
Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
372
diff
changeset
|
5297 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
|
5298 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
|
5299 _transparent[index] = 1; |
d04b0699fc28
Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
372
diff
changeset
|
5300 else |
d04b0699fc28
Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
372
diff
changeset
|
5301 _transparent[index] = 0; |
d04b0699fc28
Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
372
diff
changeset
|
5302 |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5303 _background[index] = color; |
3 | 5304 DW_MUTEX_UNLOCK; |
5305 } | |
5306 | |
5307 GdkGC *_set_colors(GdkWindow *window) | |
5308 { | |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5309 GdkGC *gc = NULL; |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5310 int index = _find_thread_index(dw_thread_id()); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5311 |
3 | 5312 if(!window) |
5313 return NULL; | |
5314 gc = gdk_gc_new(window); | |
5315 if(gc) | |
5316 { | |
373
d04b0699fc28
Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
372
diff
changeset
|
5317 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
|
5318 gdk_gc_set_background(gc, &_background[index]); |
3 | 5319 } |
5320 return gc; | |
5321 } | |
5322 | |
5323 /* Draw a point on a window (preferably a render window). | |
5324 * Parameters: | |
5325 * handle: Handle to the window. | |
5326 * pixmap: Handle to the pixmap. (choose only one of these) | |
5327 * x: X coordinate. | |
5328 * y: Y coordinate. | |
5329 */ | |
5330 void dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y) | |
5331 { | |
5332 int _locked_by_me = FALSE; | |
5333 GdkGC *gc = NULL; | |
5334 | |
5335 DW_MUTEX_LOCK; | |
5336 if(handle) | |
5337 gc = _set_colors(handle->window); | |
5338 else if(pixmap) | |
5339 gc = _set_colors(pixmap->pixmap); | |
5340 if(gc) | |
5341 { | |
5342 gdk_draw_point(handle ? handle->window : pixmap->pixmap, gc, x, y); | |
5343 gdk_gc_unref(gc); | |
5344 } | |
5345 DW_MUTEX_UNLOCK; | |
5346 } | |
5347 | |
5348 /* Draw a line on a window (preferably a render window). | |
5349 * Parameters: | |
5350 * handle: Handle to the window. | |
5351 * pixmap: Handle to the pixmap. (choose only one of these) | |
5352 * x1: First X coordinate. | |
5353 * y1: First Y coordinate. | |
5354 * x2: Second X coordinate. | |
5355 * y2: Second Y coordinate. | |
5356 */ | |
5357 void dw_draw_line(HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2) | |
5358 { | |
5359 int _locked_by_me = FALSE; | |
5360 GdkGC *gc = NULL; | |
5361 | |
5362 DW_MUTEX_LOCK; | |
5363 if(handle) | |
5364 gc = _set_colors(handle->window); | |
5365 else if(pixmap) | |
5366 gc = _set_colors(pixmap->pixmap); | |
5367 if(gc) | |
5368 { | |
5369 gdk_draw_line(handle ? handle->window : pixmap->pixmap, gc, x1, y1, x2, y2); | |
5370 gdk_gc_unref(gc); | |
5371 } | |
5372 DW_MUTEX_UNLOCK; | |
5373 } | |
5374 | |
5375 /* Draw a rectangle on a window (preferably a render window). | |
5376 * Parameters: | |
5377 * handle: Handle to the window. | |
5378 * pixmap: Handle to the pixmap. (choose only one of these) | |
5379 * x: X coordinate. | |
5380 * y: Y coordinate. | |
5381 * width: Width of rectangle. | |
5382 * height: Height of rectangle. | |
5383 */ | |
5384 void dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height) | |
5385 { | |
5386 int _locked_by_me = FALSE; | |
5387 GdkGC *gc = NULL; | |
5388 | |
5389 DW_MUTEX_LOCK; | |
5390 if(handle) | |
5391 gc = _set_colors(handle->window); | |
5392 else if(pixmap) | |
5393 gc = _set_colors(pixmap->pixmap); | |
5394 if(gc) | |
5395 { | |
5396 gdk_draw_rectangle(handle ? handle->window : pixmap->pixmap, gc, fill, x, y, width, height); | |
5397 gdk_gc_unref(gc); | |
5398 } | |
5399 DW_MUTEX_UNLOCK; | |
5400 } | |
5401 | |
5402 /* Draw text on a window (preferably a render window). | |
5403 * Parameters: | |
5404 * handle: Handle to the window. | |
5405 * pixmap: Handle to the pixmap. (choose only one of these) | |
5406 * x: X coordinate. | |
5407 * y: Y coordinate. | |
5408 * text: Text to be displayed. | |
5409 */ | |
5410 void dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text) | |
5411 { | |
5412 int _locked_by_me = FALSE; | |
5413 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
|
5414 #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
|
5415 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
|
5416 #else |
3 | 5417 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
|
5418 #endif |
3 | 5419 char *fontname = "fixed"; |
5420 | |
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
|
5421 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
|
5422 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
|
5423 |
3 | 5424 DW_MUTEX_LOCK; |
5425 if(handle) | |
5426 { | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5427 fontname = (char *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_fontname"); |
3 | 5428 gc = _set_colors(handle->window); |
5429 } | |
5430 else if(pixmap) | |
5431 { | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5432 fontname = (char *)gtk_object_get_data(GTK_OBJECT(pixmap->handle), "_dw_fontname"); |
3 | 5433 gc = _set_colors(pixmap->pixmap); |
5434 } | |
5435 if(gc) | |
5436 { | |
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
|
5437 #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
|
5438 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
|
5439 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
|
5440 { |
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
|
5441 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
|
5442 |
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
|
5443 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
|
5444 { |
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
|
5445 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
|
5446 |
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
|
5447 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
|
5448 { |
372
3ef2cf70ee07
Code for drawing text with a background color on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
369
diff
changeset
|
5449 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
|
5450 |
373
d04b0699fc28
Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
372
diff
changeset
|
5451 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
|
5452 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
|
5453 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
|
5454 |
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
|
5455 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
|
5456 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
|
5457 else |
3ef2cf70ee07
Code for drawing text with a background color on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
369
diff
changeset
|
5458 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
|
5459 |
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 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
|
5461 } |
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
|
5462 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
|
5463 } |
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
|
5464 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
|
5465 } |
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
|
5466 #else |
3 | 5467 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
|
5468 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
|
5469 font = gdk_font_load("fixed"); |
3 | 5470 if(font) |
5471 { | |
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
|
5472 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
|
5473 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
|
5474 |
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
|
5475 /* 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
|
5476 * 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
|
5477 * 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
|
5478 */ |
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
|
5479 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
|
5480 /* 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
|
5481 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
|
5482 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
|
5483 { |
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
|
5484 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
|
5485 |
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
|
5486 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
|
5487 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
|
5488 { |
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
|
5489 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
|
5490 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
|
5491 } |
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
|
5492 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
|
5493 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
|
5494 } |
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
|
5495 gdk_draw_text(handle ? handle->window : pixmap->pixmap, font, gc, x, y + ascent + 1, text, strlen(text)); |
3 | 5496 gdk_font_unref(font); |
5497 } | |
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
|
5498 #endif |
149
6028f787f7c8
Fixed a graphics context leak in dw_draw_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
148
diff
changeset
|
5499 gdk_gc_unref(gc); |
3 | 5500 } |
5501 DW_MUTEX_UNLOCK; | |
5502 } | |
5503 | |
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
|
5504 /* 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
|
5505 * 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
|
5506 * 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
|
5507 * 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
|
5508 * 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
|
5509 * 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
|
5510 * 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
|
5511 */ |
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
|
5512 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
|
5513 { |
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
|
5514 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
|
5515 #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
|
5516 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
|
5517 #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
|
5518 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
|
5519 #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
|
5520 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
|
5521 |
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
|
5522 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
|
5523 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
|
5524 |
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
|
5525 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
|
5526 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
|
5527 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
|
5528 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
|
5529 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
|
5530 |
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
|
5531 #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
|
5532 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
|
5533 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
|
5534 { |
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
|
5535 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
|
5536 |
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
|
5537 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
|
5538 { |
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
|
5539 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
|
5540 |
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
|
5541 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
|
5542 { |
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 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
|
5544 |
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
|
5545 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
|
5546 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
|
5547 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
|
5548 |
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
|
5549 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
|
5550 *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
|
5551 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
|
5552 *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
|
5553 |
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
|
5554 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
|
5555 } |
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
|
5556 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
|
5557 } |
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
|
5558 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
|
5559 } |
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 #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
|
5561 |
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
|
5562 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
|
5563 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
|
5564 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
|
5565 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
|
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(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
|
5568 *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
|
5569 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
|
5570 *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
|
5571 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
|
5572 } |
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
|
5573 #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
|
5574 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
|
5575 } |
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
|
5576 |
3 | 5577 /* |
5578 * Creates a pixmap with given parameters. | |
5579 * Parameters: | |
5580 * handle: Window handle the pixmap is associated with. | |
5581 * width: Width of the pixmap in pixels. | |
5582 * height: Height of the pixmap in pixels. | |
5583 * depth: Color depth of the pixmap. | |
5584 * Returns: | |
5585 * A handle to a pixmap or NULL on failure. | |
5586 */ | |
5587 HPIXMAP dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth) | |
5588 { | |
5589 int _locked_by_me = FALSE; | |
5590 HPIXMAP pixmap; | |
5591 | |
5592 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) | |
5593 return NULL; | |
5594 | |
5595 if (!depth) | |
66
664a274a46a6
Fixed color depth problem when creating a new pixmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
63
diff
changeset
|
5596 depth = -1; |
3 | 5597 |
5598 pixmap->width = width; pixmap->height = height; | |
5599 | |
5600 | |
5601 DW_MUTEX_LOCK; | |
5602 pixmap->handle = handle; | |
5603 pixmap->pixmap = gdk_pixmap_new(handle->window, width, height, depth); | |
5604 DW_MUTEX_UNLOCK; | |
5605 return pixmap; | |
5606 } | |
5607 | |
5608 /* | |
241
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5609 * Creates a pixmap from a file. |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5610 * Parameters: |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5611 * 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
|
5612 * 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
|
5613 * DW pick the appropriate file extension. |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5614 * (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
|
5615 * Returns: |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5616 * 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
|
5617 */ |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5618 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
|
5619 { |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5620 int _locked_by_me = FALSE; |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5621 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
|
5622 #ifndef USE_IMLIB |
241
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5623 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
|
5624 #endif |
241
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5625 #if GTK_MAJOR_VERSION > 1 |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5626 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
|
5627 #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
|
5628 GdkImlibImage *image; |
241
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5629 #endif |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5630 char *file = alloca(strlen(filename) + 5); |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5631 |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5632 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
|
5633 return NULL; |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5634 |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5635 strcpy(file, filename); |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5636 |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5637 /* 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
|
5638 if(access(file, 04) != 0) |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5639 { |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5640 /* Try with .xpm extention */ |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5641 strcat(file, ".xpm"); |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5642 if(access(file, 04) != 0) |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5643 { |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5644 free(pixmap); |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5645 return NULL; |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5646 } |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5647 } |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5648 |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5649 DW_MUTEX_LOCK; |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5650 #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
|
5651 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
|
5652 |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5653 pixmap->width = gdk_pixbuf_get_width(pixbuf); |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5654 pixmap->height = gdk_pixbuf_get_height(pixbuf); |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5655 |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5656 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
|
5657 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
|
5658 #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
|
5659 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
|
5660 |
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
|
5661 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
|
5662 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
|
5663 |
245
11baf43efbc2
Must call gdk_imlib_render() before gdk_imlib_copy_image().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
244
diff
changeset
|
5664 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
|
5665 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
|
5666 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
|
5667 #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
|
5668 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
|
5669 #endif |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5670 pixmap->handle = handle; |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5671 DW_MUTEX_UNLOCK; |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5672 return pixmap; |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5673 } |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5674 |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5675 /* |
3 | 5676 * Creates a pixmap from internal resource graphic specified by id. |
5677 * Parameters: | |
5678 * handle: Window handle the pixmap is associated with. | |
5679 * id: Resource ID associated with requested pixmap. | |
5680 * Returns: | |
5681 * A handle to a pixmap or NULL on failure. | |
5682 */ | |
5683 HPIXMAP dw_pixmap_grab(HWND handle, ULONG id) | |
5684 { | |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5685 GdkBitmap *bitmap = NULL; |
3 | 5686 HPIXMAP pixmap; |
5687 int _locked_by_me = FALSE; | |
5688 | |
5689 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) | |
5690 return NULL; | |
5691 | |
5692 | |
5693 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
|
5694 pixmap->pixmap = _find_pixmap(&bitmap, id, handle, &pixmap->width, &pixmap->height); |
3 | 5695 if(pixmap->pixmap) |
5696 { | |
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
|
5697 #if GTK_MAJOR_VERSION < 2 |
3 | 5698 GdkPixmapPrivate *pvt = (GdkPixmapPrivate *)pixmap->pixmap; |
5699 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
|
5700 #endif |
3 | 5701 } |
5702 DW_MUTEX_UNLOCK; | |
5703 return pixmap; | |
5704 } | |
5705 | |
5706 /* Call this after drawing to the screen to make sure | |
5707 * anything you have drawn is visible. | |
5708 */ | |
5709 void dw_flush(void) | |
5710 { | |
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
|
5711 #if GTK_MAJOR_VERSION < 2 |
3 | 5712 int _locked_by_me = FALSE; |
5713 | |
5714 DW_MUTEX_LOCK; | |
5715 gdk_flush(); | |
5716 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
|
5717 #endif |
3 | 5718 } |
5719 | |
5720 /* | |
5721 * Destroys an allocated pixmap. | |
5722 * Parameters: | |
5723 * pixmap: Handle to a pixmap returned by | |
5724 * dw_pixmap_new.. | |
5725 */ | |
5726 void dw_pixmap_destroy(HPIXMAP pixmap) | |
5727 { | |
5728 int _locked_by_me = FALSE; | |
5729 | |
5730 DW_MUTEX_LOCK; | |
5731 gdk_pixmap_unref(pixmap->pixmap); | |
5732 free(pixmap); | |
5733 DW_MUTEX_UNLOCK; | |
5734 } | |
5735 | |
5736 /* | |
5737 * Copies from one item to another. | |
5738 * Parameters: | |
5739 * dest: Destination window handle. | |
5740 * destp: Destination pixmap. (choose only one). | |
5741 * xdest: X coordinate of destination. | |
5742 * ydest: Y coordinate of destination. | |
5743 * width: Width of area to copy. | |
5744 * height: Height of area to copy. | |
5745 * src: Source window handle. | |
5746 * srcp: Source pixmap. (choose only one). | |
5747 * xsrc: X coordinate of source. | |
5748 * ysrc: Y coordinate of source. | |
5749 */ | |
5750 void dw_pixmap_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc) | |
5751 { | |
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
|
5752 /* 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
|
5753 * 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
|
5754 * 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
|
5755 * 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
|
5756 */ |
3 | 5757 int _locked_by_me = FALSE; |
5758 GdkGC *gc = NULL; | |
5759 | |
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
|
5760 if((!dest && (!destp || !destp->pixmap)) || (!src && (!srcp || !srcp->pixmap))) |
3 | 5761 return; |
5762 | |
5763 DW_MUTEX_LOCK; | |
5764 if(dest) | |
5765 gc = _set_colors(dest->window); | |
5766 else if(src) | |
5767 gc = _set_colors(src->window); | |
5768 else if(destp) | |
5769 gc = gdk_gc_new(destp->pixmap); | |
5770 else if(srcp) | |
5771 gc = gdk_gc_new(srcp->pixmap); | |
122
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
5772 |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
5773 if(gc) |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
5774 { |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
5775 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
|
5776 gdk_gc_unref(gc); |
3 | 5777 } |
5778 DW_MUTEX_UNLOCK; | |
5779 } | |
5780 | |
5781 /* | |
5782 * Emits a beep. | |
5783 * Parameters: | |
5784 * freq: Frequency. | |
5785 * dur: Duration. | |
5786 */ | |
5787 void dw_beep(int freq, int dur) | |
5788 { | |
5789 int _locked_by_me = FALSE; | |
5790 | |
5791 DW_MUTEX_LOCK; | |
5792 gdk_beep(); | |
5793 DW_MUTEX_UNLOCK; | |
5794 } | |
5795 | |
157
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5796 void _my_strlwr(char *buf) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5797 { |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5798 int z, len = strlen(buf); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5799 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5800 for(z=0;z<len;z++) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5801 { |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5802 if(buf[z] >= 'A' && buf[z] <= 'Z') |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5803 buf[z] -= 'A' - 'a'; |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5804 } |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5805 } |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5806 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5807 /* Open a shared library and return a handle. |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5808 * Parameters: |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5809 * name: Base name of the shared library. |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5810 * handle: Pointer to a module handle, |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5811 * will be filled in with the handle. |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5812 */ |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5813 int dw_module_load(char *name, HMOD *handle) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5814 { |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5815 int len; |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5816 char *newname; |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5817 char errorbuf[1024]; |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5818 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5819 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5820 if(!handle) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5821 return -1; |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5822 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5823 if((len = strlen(name)) == 0) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5824 return -1; |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5825 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5826 /* Lenth + "lib" + ".so" + NULL */ |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5827 newname = malloc(len + 7); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5828 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5829 if(!newname) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5830 return -1; |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5831 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5832 sprintf(newname, "lib%s.so", name); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5833 _my_strlwr(newname); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5834 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5835 *handle = dlopen(newname, RTLD_NOW); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5836 if(*handle == NULL) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5837 { |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5838 strncpy(errorbuf, dlerror(), 1024); |
164
d35771f70bdd
Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
163
diff
changeset
|
5839 printf("%s\n", errorbuf); |
157
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5840 sprintf(newname, "lib%s.so", name); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5841 *handle = dlopen(newname, RTLD_NOW); |
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 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5844 free(newname); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5845 |
163
0322836c5299
Return -1 on error from dw_module_load().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
162
diff
changeset
|
5846 return (NULL == *handle) ? -1 : 0; |
157
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5847 } |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5848 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5849 /* Queries the address of a symbol within open handle. |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5850 * Parameters: |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5851 * handle: Module handle returned by dw_module_load() |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5852 * name: Name of the symbol you want the address of. |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5853 * func: A pointer to a function pointer, to obtain |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5854 * the address. |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5855 */ |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5856 int dw_module_symbol(HMOD handle, char *name, void**func) |
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 if(!func || !name) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5859 return -1; |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5860 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5861 if(strlen(name) == 0) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5862 return -1; |
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 *func = (void*)dlsym(handle, name); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5865 return (NULL == *func); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5866 } |
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 /* Frees the shared library previously opened. |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5869 * Parameters: |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5870 * handle: Module handle returned by dw_module_load() |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5871 */ |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5872 int dw_module_close(HMOD handle) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5873 { |
162
df59a3fc6de6
Fixed a minor bug in dw_module_close().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
157
diff
changeset
|
5874 if(handle) |
df59a3fc6de6
Fixed a minor bug in dw_module_close().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
157
diff
changeset
|
5875 return dlclose(handle); |
df59a3fc6de6
Fixed a minor bug in dw_module_close().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
157
diff
changeset
|
5876 return 0; |
157
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5877 } |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5878 |
3 | 5879 /* |
5880 * Returns the handle to an unnamed mutex semaphore. | |
5881 */ | |
5882 HMTX dw_mutex_new(void) | |
5883 { | |
239
403b07f873e1
Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
237
diff
changeset
|
5884 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
|
5885 |
403b07f873e1
Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
237
diff
changeset
|
5886 pthread_mutex_init(mutex, NULL); |
3 | 5887 return mutex; |
5888 } | |
5889 | |
5890 /* | |
5891 * Closes a semaphore created by dw_mutex_new(). | |
5892 * Parameters: | |
5893 * mutex: The handle to the mutex returned by dw_mutex_new(). | |
5894 */ | |
5895 void dw_mutex_close(HMTX mutex) | |
5896 { | |
239
403b07f873e1
Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
237
diff
changeset
|
5897 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
|
5898 { |
403b07f873e1
Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
237
diff
changeset
|
5899 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
|
5900 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
|
5901 } |
3 | 5902 } |
5903 | |
5904 /* | |
5905 * Tries to gain access to the semaphore, if it can't it blocks. | |
5906 * Parameters: | |
5907 * mutex: The handle to the mutex returned by dw_mutex_new(). | |
5908 */ | |
5909 void dw_mutex_lock(HMTX mutex) | |
5910 { | |
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
|
5911 /* 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
|
5912 * 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
|
5913 */ |
baaf4b04d284
Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
94
diff
changeset
|
5914 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
|
5915 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
|
5916 |
239
403b07f873e1
Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
237
diff
changeset
|
5917 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
|
5918 |
baaf4b04d284
Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
94
diff
changeset
|
5919 /* 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
|
5920 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
|
5921 gdk_threads_enter(); |
3 | 5922 } |
5923 | |
5924 /* | |
5925 * Reliquishes the access to the semaphore. | |
5926 * Parameters: | |
5927 * mutex: The handle to the mutex returned by dw_mutex_new(). | |
5928 */ | |
5929 void dw_mutex_unlock(HMTX mutex) | |
5930 { | |
239
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_unlock(mutex); |
3 | 5932 } |
5933 | |
5934 /* | |
5935 * Returns the handle to an unnamed event semaphore. | |
5936 */ | |
5937 HEV dw_event_new(void) | |
5938 { | |
5939 HEV eve = (HEV)malloc(sizeof(struct _dw_unix_event)); | |
5940 | |
5941 if(!eve) | |
5942 return NULL; | |
5943 | |
5944 /* We need to be careful here, mutexes on Linux are | |
5945 * FAST by default but are error checking on other | |
5946 * systems such as FreeBSD and OS/2, perhaps others. | |
5947 */ | |
5948 pthread_mutex_init (&(eve->mutex), NULL); | |
5949 pthread_mutex_lock (&(eve->mutex)); | |
5950 pthread_cond_init (&(eve->event), NULL); | |
5951 | |
5952 pthread_mutex_unlock (&(eve->mutex)); | |
5953 eve->alive = 1; | |
5954 eve->posted = 0; | |
5955 | |
5956 return eve; | |
5957 } | |
5958 | |
5959 /* | |
5960 * Resets a semaphore created by dw_event_new(). | |
5961 * Parameters: | |
5962 * eve: The handle to the event returned by dw_event_new(). | |
5963 */ | |
5964 int dw_event_reset (HEV eve) | |
5965 { | |
5966 if(!eve) | |
5967 return FALSE; | |
5968 | |
5969 pthread_mutex_lock (&(eve->mutex)); | |
5970 pthread_cond_broadcast (&(eve->event)); | |
5971 pthread_cond_init (&(eve->event), NULL); | |
5972 eve->posted = 0; | |
5973 pthread_mutex_unlock (&(eve->mutex)); | |
5974 return 0; | |
5975 } | |
5976 | |
5977 /* | |
5978 * Posts a semaphore created by dw_event_new(). Causing all threads | |
5979 * waiting on this event in dw_event_wait to continue. | |
5980 * Parameters: | |
5981 * eve: The handle to the event returned by dw_event_new(). | |
5982 */ | |
5983 int dw_event_post (HEV eve) | |
5984 { | |
5985 if(!eve) | |
5986 return FALSE; | |
5987 | |
5988 pthread_mutex_lock (&(eve->mutex)); | |
5989 pthread_cond_broadcast (&(eve->event)); | |
5990 eve->posted = 1; | |
5991 pthread_mutex_unlock (&(eve->mutex)); | |
5992 return 0; | |
5993 } | |
5994 | |
5995 /* | |
5996 * Waits on a semaphore created by dw_event_new(), until the | |
5997 * event gets posted or until the timeout expires. | |
5998 * Parameters: | |
5999 * eve: The handle to the event returned by dw_event_new(). | |
6000 */ | |
6001 int dw_event_wait(HEV eve, unsigned long timeout) | |
6002 { | |
6003 int rc; | |
6004 struct timeval now; | |
6005 struct timespec timeo; | |
6006 | |
6007 if(!eve) | |
6008 return FALSE; | |
6009 | |
6010 if(eve->posted) | |
6011 return 0; | |
6012 | |
6013 pthread_mutex_lock (&(eve->mutex)); | |
6014 gettimeofday(&now, 0); | |
6015 timeo.tv_sec = now.tv_sec + (timeout / 1000); | |
6016 timeo.tv_nsec = now.tv_usec * 1000; | |
6017 rc = pthread_cond_timedwait (&(eve->event), &(eve->mutex), &timeo); | |
6018 pthread_mutex_unlock (&(eve->mutex)); | |
6019 if(!rc) | |
6020 return 1; | |
6021 if(rc == ETIMEDOUT) | |
6022 return -1; | |
6023 return 0; | |
6024 } | |
6025 | |
6026 /* | |
6027 * Closes a semaphore created by dw_event_new(). | |
6028 * Parameters: | |
6029 * eve: The handle to the event returned by dw_event_new(). | |
6030 */ | |
6031 int dw_event_close(HEV *eve) | |
6032 { | |
6033 if(!eve || !(*eve)) | |
6034 return FALSE; | |
6035 | |
6036 pthread_mutex_lock (&((*eve)->mutex)); | |
6037 pthread_cond_destroy (&((*eve)->event)); | |
6038 pthread_mutex_unlock (&((*eve)->mutex)); | |
6039 pthread_mutex_destroy (&((*eve)->mutex)); | |
6040 free(*eve); | |
6041 *eve = NULL; | |
6042 | |
6043 return TRUE; | |
6044 } | |
6045 | |
6046 /* | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6047 * Setup thread independent color sets. |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6048 */ |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6049 void _dwthreadstart(void *data) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6050 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6051 void (*threadfunc)(void *) = NULL; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6052 void **tmp = (void **)data; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6053 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6054 threadfunc = (void (*)(void *))tmp[0]; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6055 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6056 _dw_thread_add(dw_thread_id()); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6057 threadfunc(tmp[1]); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6058 _dw_thread_remove(dw_thread_id()); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6059 free(tmp); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6060 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6061 /* |
3 | 6062 * Creates a new thread with a starting point of func. |
6063 * Parameters: | |
6064 * func: Function which will be run in the new thread. | |
6065 * data: Parameter(s) passed to the function. | |
6066 * stack: Stack size of new thread (OS/2 and Windows only). | |
6067 */ | |
6068 DWTID dw_thread_new(void *func, void *data, int stack) | |
6069 { | |
6070 DWTID gtkthread; | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6071 void **tmp = malloc(sizeof(void *) * 2); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6072 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6073 tmp[0] = func; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6074 tmp[1] = data; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6075 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6076 pthread_create(>kthread, NULL, (void *)_dwthreadstart, (void *)tmp); |
3 | 6077 return gtkthread; |
6078 } | |
6079 | |
6080 /* | |
6081 * Ends execution of current thread immediately. | |
6082 */ | |
6083 void dw_thread_end(void) | |
6084 { | |
6085 pthread_exit(NULL); | |
6086 } | |
6087 | |
6088 /* | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6089 * Returns the current thread's ID. |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6090 */ |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6091 DWTID dw_thread_id(void) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6092 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6093 return (DWTID)pthread_self(); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6094 } |
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 /* |
3 | 6097 * Cleanly terminates a DW session, should be signal handler safe. |
6098 * Parameters: | |
6099 * exitcode: Exit code reported to the operating system. | |
6100 */ | |
6101 void dw_exit(int exitcode) | |
6102 { | |
6103 exit(exitcode); | |
6104 } | |
6105 | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6106 #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
|
6107 |
3 | 6108 /* |
6109 * Pack windows (widgets) into a box from the end (or bottom). | |
6110 * Parameters: | |
6111 * box: Window handle of the box to be packed into. | |
6112 * item: Window handle of the item to be back. | |
6113 * width: Width in pixels of the item or -1 to be self determined. | |
6114 * height: Height in pixels of the item or -1 to be self determined. | |
6115 * hsize: TRUE if the window (widget) should expand horizontally to fill space given. | |
6116 * vsize: TRUE if the window (widget) should expand vertically to fill space given. | |
6117 * pad: Number of pixels of padding around the item. | |
6118 */ | |
6119 void dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) | |
6120 { | |
6121 int _locked_by_me = FALSE; | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6122 GtkWidget *tmp; |
3 | 6123 |
6124 if(!box) | |
6125 return; | |
6126 | |
6127 DW_MUTEX_LOCK; | |
6128 | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6129 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
|
6130 box = tmp; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6131 |
3 | 6132 if(!item) |
6133 { | |
6134 item = gtk_label_new(""); | |
6135 gtk_widget_show(item); | |
6136 } | |
6137 | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6138 if(GTK_IS_TABLE(box)) |
3 | 6139 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6140 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
|
6141 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
|
6142 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6143 /* 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
|
6144 * 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
|
6145 * 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
|
6146 * 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
|
6147 */ |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6148 if(GTK_IS_TABLE(item)) |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6149 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6150 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
|
6151 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6152 if(eventbox) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6153 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6154 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
|
6155 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
|
6156 item = eventbox; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6157 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6158 } |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6159 |
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
|
6160 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
|
6161 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
|
6162 else |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6163 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
|
6164 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6165 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
|
6166 gtk_object_set_data(GTK_OBJECT(box), "_dw_boxcount", (gpointer)boxcount + 1); |
3 | 6167 gtk_widget_set_usize(item, width, height); |
6168 if(GTK_IS_RADIO_BUTTON(item)) | |
6169 { | |
6170 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
|
6171 GtkWidget *groupstart = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(box), "_dw_group"); |
3 | 6172 |
6173 if(groupstart) | |
6174 { | |
6175 group = gtk_radio_button_group(GTK_RADIO_BUTTON(groupstart)); | |
6176 gtk_radio_button_set_group(GTK_RADIO_BUTTON(item), group); | |
6177 } | |
6178 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
|
6179 gtk_object_set_data(GTK_OBJECT(box), "_dw_group", (gpointer)item); |
3 | 6180 } |
6181 } | |
6182 else | |
6183 { | |
6184 GtkWidget *vbox = gtk_vbox_new(FALSE, 0); | |
6185 | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6186 if(GTK_IS_TABLE(item)) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6187 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6188 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
|
6189 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6190 if(eventbox) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6191 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6192 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
|
6193 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
|
6194 item = eventbox; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6195 } |
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 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6198 gtk_container_border_width(GTK_CONTAINER(box), pad); |
3 | 6199 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
|
6200 gtk_box_pack_end(GTK_BOX(vbox), item, TRUE, TRUE, 0); |
3 | 6201 gtk_widget_show(vbox); |
6202 | |
6203 gtk_widget_set_usize(item, width, height); | |
6204 gtk_object_set_user_data(GTK_OBJECT(box), vbox); | |
6205 } | |
6206 DW_MUTEX_UNLOCK; | |
6207 } | |
6208 | |
6209 /* | |
6210 * Sets the size of a given window (widget). | |
6211 * Parameters: | |
6212 * handle: Window (widget) handle. | |
6213 * width: New width in pixels. | |
6214 * height: New height in pixels. | |
6215 */ | |
6216 void dw_window_set_usize(HWND handle, unsigned long width, unsigned long height) | |
6217 { | |
6218 int _locked_by_me = FALSE; | |
6219 | |
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
|
6220 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
|
6221 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
|
6222 |
3 | 6223 DW_MUTEX_LOCK; |
6224 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
|
6225 { |
3 | 6226 _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
|
6227 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
|
6228 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
|
6229 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
|
6230 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
|
6231 { |
49ac97060328
Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
271
diff
changeset
|
6232 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
|
6233 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
|
6234 } |
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
|
6235 } |
3 | 6236 else |
6237 gtk_widget_set_usize(handle, width, height); | |
6238 DW_MUTEX_UNLOCK; | |
6239 } | |
6240 | |
6241 /* | |
6242 * Returns the width of the screen. | |
6243 */ | |
6244 int dw_screen_width(void) | |
6245 { | |
6246 int retval; | |
6247 int _locked_by_me = FALSE; | |
6248 | |
6249 DW_MUTEX_LOCK; | |
6250 retval = gdk_screen_width(); | |
6251 DW_MUTEX_UNLOCK; | |
6252 return retval; | |
6253 } | |
6254 | |
6255 /* | |
6256 * Returns the height of the screen. | |
6257 */ | |
6258 int dw_screen_height(void) | |
6259 { | |
6260 int retval; | |
6261 int _locked_by_me = FALSE; | |
6262 | |
6263 DW_MUTEX_UNLOCK; | |
6264 retval = gdk_screen_height(); | |
6265 DW_MUTEX_UNLOCK; | |
6266 return retval; | |
6267 } | |
6268 | |
6269 /* This should return the current color depth */ | |
6270 unsigned long dw_color_depth(void) | |
6271 { | |
6272 int retval; | |
6273 int _locked_by_me = FALSE; | |
6274 | |
6275 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
|
6276 retval = gdk_visual_get_best_depth(); |
3 | 6277 DW_MUTEX_UNLOCK; |
6278 return retval; | |
6279 } | |
6280 | |
6281 /* | |
6282 * Sets the position of a given window (widget). | |
6283 * Parameters: | |
6284 * handle: Window (widget) handle. | |
6285 * x: X location from the bottom left. | |
6286 * y: Y location from the bottom left. | |
6287 */ | |
6288 void dw_window_set_pos(HWND handle, unsigned long x, unsigned long y) | |
6289 { | |
6290 int _locked_by_me = FALSE; | |
6291 | |
6292 DW_MUTEX_LOCK; | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
6293 if(handle && handle->window) |
3 | 6294 gdk_window_move(handle->window, x, y); |
6295 DW_MUTEX_UNLOCK; | |
6296 } | |
6297 | |
6298 /* | |
6299 * Sets the position and size of a given window (widget). | |
6300 * Parameters: | |
6301 * handle: Window (widget) handle. | |
6302 * x: X location from the bottom left. | |
6303 * y: Y location from the bottom left. | |
6304 * width: Width of the widget. | |
6305 * height: Height of the widget. | |
6306 */ | |
6307 void dw_window_set_pos_size(HWND handle, unsigned long x, unsigned long y, unsigned long width, unsigned long height) | |
6308 { | |
6309 int _locked_by_me = FALSE; | |
6310 | |
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
|
6311 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
|
6312 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
|
6313 |
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
|
6314 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
|
6315 if(GTK_IS_WINDOW(handle)) |
3 | 6316 { |
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
|
6317 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
|
6318 gtk_widget_set_uposition(handle, x, y); |
3 | 6319 } |
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
|
6320 else if(handle->window) |
3 | 6321 { |
6322 gdk_window_resize(handle->window, width, height); | |
6323 gdk_window_move(handle->window, x, y); | |
6324 } | |
6325 DW_MUTEX_UNLOCK; | |
6326 } | |
6327 | |
6328 /* | |
6329 * Gets the position and size of a given window (widget). | |
6330 * Parameters: | |
6331 * handle: Window (widget) handle. | |
6332 * x: X location from the bottom left. | |
6333 * y: Y location from the bottom left. | |
6334 * width: Width of the widget. | |
6335 * height: Height of the widget. | |
6336 */ | |
6337 void dw_window_get_pos_size(HWND handle, ULONG *x, ULONG *y, ULONG *width, ULONG *height) | |
6338 { | |
6339 int _locked_by_me = FALSE; | |
6340 gint gx, gy, gwidth, gheight, gdepth; | |
6341 | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
6342 if(handle && handle->window) |
3 | 6343 { |
6344 DW_MUTEX_LOCK; | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
6345 |
3 | 6346 gdk_window_get_geometry(handle->window, &gx, &gy, &gwidth, &gheight, &gdepth); |
6347 gdk_window_get_root_origin(handle->window, &gx, &gy); | |
6348 if(x) | |
6349 *x = gx; | |
6350 if(y) | |
6351 *y = gy; | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6352 if(GTK_IS_WINDOW(handle)) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6353 { |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6354 if(width) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6355 *width = gwidth + _dw_border_width; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6356 if(height) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6357 *height = gheight + _dw_border_height; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6358 } |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6359 else |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6360 { |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6361 if(width) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6362 *width = gwidth; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6363 if(height) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6364 *height = gheight; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6365 } |
3 | 6366 DW_MUTEX_UNLOCK; |
6367 } | |
6368 } | |
6369 | |
6370 /* | |
6371 * Sets the style of a given window (widget). | |
6372 * Parameters: | |
6373 * handle: Window (widget) handle. | |
6374 * width: New width in pixels. | |
6375 * height: New height in pixels. | |
6376 */ | |
6377 void dw_window_set_style(HWND handle, unsigned long style, unsigned long mask) | |
6378 { | |
6379 GtkWidget *handle2 = handle; | |
6380 int _locked_by_me = FALSE; | |
6381 | |
6382 DW_MUTEX_LOCK; | |
6383 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
6384 { | |
6385 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
6386 if(tmp) | |
6387 handle2 = tmp; | |
6388 } | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6389 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
|
6390 { |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6391 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
|
6392 { |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6393 gfloat x, y; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6394 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6395 x = y = DW_LEFT; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6396 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6397 if(style & DW_DT_CENTER) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6398 x = DW_CENTER; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6399 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6400 if(style & DW_DT_VCENTER) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6401 y = DW_CENTER; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6402 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6403 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
|
6404 } |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6405 if(style & DW_DT_WORDBREAK) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6406 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
|
6407 } |
3 | 6408 DW_MUTEX_UNLOCK; |
6409 } | |
6410 | |
6411 /* | |
6412 * Adds a new page to specified notebook. | |
6413 * Parameters: | |
6414 * handle: Window (widget) handle. | |
6415 * flags: Any additional page creation flags. | |
6416 * front: If TRUE page is added at the beginning. | |
6417 */ | |
6418 unsigned long dw_notebook_page_new(HWND handle, unsigned long flags, int front) | |
6419 { | |
6420 int z; | |
6421 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
|
6422 GtkWidget **pagearray; |
3 | 6423 |
6424 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
|
6425 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
|
6426 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6427 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
|
6428 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6429 for(z=0;z<256;z++) |
3 | 6430 { |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6431 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
|
6432 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6433 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
|
6434 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
|
6435 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6436 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
|
6437 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
|
6438 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6439 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
|
6440 /* 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
|
6441 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
|
6442 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
|
6443 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
|
6444 } |
3 | 6445 } |
15
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
6446 } |
3 | 6447 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
|
6448 |
3 | 6449 /* Hopefully this won't happen. */ |
6450 return 256; | |
6451 } | |
6452 | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6453 /* 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
|
6454 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
|
6455 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6456 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
|
6457 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
|
6458 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6459 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
|
6460 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6461 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
|
6462 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6463 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
|
6464 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6465 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
|
6466 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
|
6467 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6468 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6469 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6470 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
|
6471 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6472 |
3 | 6473 /* |
6474 * Remove a page from a notebook. | |
6475 * Parameters: | |
6476 * handle: Handle to the notebook widget. | |
6477 * pageid: ID of the page to be destroyed. | |
6478 */ | |
6479 void dw_notebook_page_destroy(HWND handle, unsigned int pageid) | |
6480 { | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6481 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
|
6482 GtkWidget **pagearray; |
3 | 6483 |
6484 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
|
6485 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
|
6486 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
|
6487 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6488 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
|
6489 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
|
6490 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
|
6491 } |
3 | 6492 DW_MUTEX_UNLOCK; |
6493 } | |
6494 | |
6495 /* | |
6496 * Queries the currently visible page ID. | |
6497 * Parameters: | |
6498 * handle: Handle to the notebook widget. | |
6499 */ | |
346
81fae15885d7
Implemented switch-page on OS/2, and changed the signal prototype to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
345
diff
changeset
|
6500 unsigned long dw_notebook_page_query(HWND handle) |
3 | 6501 { |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6502 int retval, phys; |
3 | 6503 int _locked_by_me = FALSE; |
6504 | |
6505 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
|
6506 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
|
6507 retval = _get_logical_page(handle, phys); |
3 | 6508 DW_MUTEX_UNLOCK; |
6509 return retval; | |
6510 } | |
6511 | |
6512 /* | |
6513 * Sets the currently visibale page ID. | |
6514 * Parameters: | |
6515 * handle: Handle to the notebook widget. | |
6516 * pageid: ID of the page to be made visible. | |
6517 */ | |
6518 void dw_notebook_page_set(HWND handle, unsigned int pageid) | |
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 int realpage, _locked_by_me = FALSE; |
3 | 6521 |
6522 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
|
6523 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
|
6524 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
|
6525 gtk_notebook_set_page(GTK_NOTEBOOK(handle), pageid); |
3 | 6526 DW_MUTEX_UNLOCK; |
6527 } | |
6528 | |
6529 | |
6530 /* | |
6531 * Sets the text on the specified notebook tab. | |
6532 * Parameters: | |
6533 * handle: Notebook handle. | |
6534 * pageid: Page ID of the tab to set. | |
6535 * text: Pointer to the text to set. | |
6536 */ | |
6537 void dw_notebook_page_set_text(HWND handle, unsigned long pageid, char *text) | |
6538 { | |
6539 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
|
6540 int realpage, _locked_by_me = FALSE; |
3 | 6541 |
6542 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
|
6543 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
|
6544 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
|
6545 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6546 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
|
6547 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
|
6548 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6549 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
|
6550 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
|
6551 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
|
6552 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6553 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6554 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
|
6555 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6556 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
|
6557 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
|
6558 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
|
6559 } |
3 | 6560 DW_MUTEX_UNLOCK; |
6561 } | |
6562 | |
6563 /* | |
6564 * Sets the text on the specified notebook tab status area. | |
6565 * Parameters: | |
6566 * handle: Notebook handle. | |
6567 * pageid: Page ID of the tab to set. | |
6568 * text: Pointer to the text to set. | |
6569 */ | |
6570 void dw_notebook_page_set_status_text(HWND handle, unsigned long pageid, char *text) | |
6571 { | |
6572 /* TODO (if possible) */ | |
6573 } | |
6574 | |
6575 /* | |
6576 * Packs the specified box into the notebook page. | |
6577 * Parameters: | |
6578 * handle: Handle to the notebook to be packed. | |
6579 * pageid: Page ID in the notebook which is being packed. | |
6580 * page: Box handle to be packed. | |
6581 */ | |
6582 void dw_notebook_pack(HWND handle, unsigned long pageid, HWND page) | |
6583 { | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6584 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
|
6585 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
|
6586 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
|
6587 char ptext[100]; |
3 | 6588 |
6589 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
|
6590 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
|
6591 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
|
6592 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
|
6593 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
|
6594 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6595 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
|
6596 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6597 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
|
6598 return; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6599 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6600 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6601 /* 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
|
6602 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
|
6603 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6604 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
|
6605 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6606 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
|
6607 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
|
6608 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6609 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
|
6610 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
|
6611 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
|
6612 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
|
6613 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
|
6614 break; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6615 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6616 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6617 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6618 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6619 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
|
6620 |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
6621 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
|
6622 |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6623 if(GTK_IS_TABLE(page)) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6624 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6625 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
|
6626 gtk_container_border_width(GTK_CONTAINER(page), pad); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6627 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6628 |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6629 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
|
6630 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
|
6631 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
|
6632 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
|
6633 else |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6634 gtk_notebook_insert_page(GTK_NOTEBOOK(handle), page, label, 256); |
3 | 6635 DW_MUTEX_UNLOCK; |
6636 } | |
6637 | |
6638 /* | |
6639 * Appends the specified text to the listbox's (or combobox) entry list. | |
6640 * Parameters: | |
6641 * handle: Handle to the listbox to be appended to. | |
6642 * text: Text to append into listbox. | |
6643 */ | |
6644 void dw_listbox_append(HWND handle, char *text) | |
6645 { | |
6646 GtkWidget *handle2 = handle; | |
6647 int _locked_by_me = FALSE; | |
6648 | |
6649 DW_MUTEX_LOCK; | |
6650 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
6651 { | |
6652 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
6653 if(tmp) | |
6654 handle2 = tmp; | |
6655 } | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6656 gtk_object_set_data(GTK_OBJECT(handle), "_dw_appending", (gpointer)1); |
3 | 6657 if(GTK_IS_LIST(handle2)) |
6658 { | |
6659 GtkWidget *list_item; | |
6660 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
|
6661 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
|
6662 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
|
6663 GdkColor *back = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle2), "_dw_backgdk"); |
3 | 6664 |
6665 list_item=gtk_list_item_new_with_label(text); | |
6666 | |
6667 if(font) | |
6668 _set_font(GTK_LIST_ITEM(list_item)->item.bin.child, font); | |
6669 if(fore && back) | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
6670 _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
|
6671 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
|
6672 DW_RGB(back->red, back->green, back->blue)); |
3 | 6673 |
6674 tmp = g_list_append(NULL, list_item); | |
6675 gtk_widget_show(list_item); | |
6676 gtk_list_append_items(GTK_LIST(handle2),tmp); | |
6677 } | |
6678 else if(GTK_IS_COMBO(handle2)) | |
6679 { | |
6680 GList *tmp = (GList *)gtk_object_get_user_data(GTK_OBJECT(handle2)); | |
6681 char *addtext = strdup(text); | |
6682 | |
6683 if(addtext) | |
6684 { | |
6685 tmp = g_list_append(tmp, addtext); | |
6686 gtk_object_set_user_data(GTK_OBJECT(handle2), tmp); | |
6687 gtk_combo_set_popdown_strings(GTK_COMBO(handle2), tmp); | |
6688 } | |
6689 } | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6690 gtk_object_set_data(GTK_OBJECT(handle), "_dw_appending", NULL); |
3 | 6691 DW_MUTEX_UNLOCK; |
6692 } | |
6693 | |
6694 /* | |
6695 * Clears the listbox's (or combobox) list of all entries. | |
6696 * Parameters: | |
6697 * handle: Handle to the listbox to be cleared. | |
6698 */ | |
6699 void dw_listbox_clear(HWND handle) | |
6700 { | |
6701 GtkWidget *handle2 = handle; | |
6702 int _locked_by_me = FALSE; | |
6703 | |
6704 DW_MUTEX_LOCK; | |
6705 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
6706 { | |
6707 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
6708 if(tmp) | |
6709 handle2 = tmp; | |
6710 } | |
6711 if(GTK_IS_COMBO(handle2)) | |
6712 { | |
6713 GList *list, *tmp = (GList *)gtk_object_get_user_data(GTK_OBJECT(handle2)); | |
6714 | |
6715 if(tmp) | |
6716 { | |
6717 list = tmp; | |
6718 while(list) | |
6719 { | |
6720 if(list->data) | |
6721 free(list->data); | |
6722 list=list->next; | |
6723 } | |
6724 g_list_free(tmp); | |
6725 } | |
6726 gtk_object_set_user_data(GTK_OBJECT(handle2), NULL); | |
6727 } | |
6728 else if(GTK_IS_LIST(handle2)) | |
6729 { | |
6730 int count = dw_listbox_count(handle); | |
6731 | |
6732 gtk_list_clear_items(GTK_LIST(handle2), 0, count - 1); | |
6733 } | |
6734 DW_MUTEX_UNLOCK; | |
6735 } | |
6736 | |
6737 /* | |
6738 * Returns the listbox's item count. | |
6739 * Parameters: | |
6740 * handle: Handle to the listbox to be counted | |
6741 */ | |
6742 int dw_listbox_count(HWND handle) | |
6743 { | |
6744 GtkWidget *handle2 = handle; | |
6745 int retval = 0; | |
6746 int _locked_by_me = FALSE; | |
6747 | |
6748 DW_MUTEX_LOCK; | |
6749 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
6750 { | |
6751 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
6752 if(tmp) | |
6753 handle2 = tmp; | |
6754 } | |
6755 else if(GTK_IS_COMBO(handle)) | |
6756 { | |
6757 handle2 = GTK_COMBO(handle)->list; | |
6758 } | |
6759 if(GTK_IS_LIST(handle2)) | |
6760 { | |
6761 GList *list = GTK_LIST(handle2)->children; | |
6762 while(list) | |
6763 { | |
6764 list = list->next; | |
6765 retval++; | |
6766 } | |
6767 } | |
6768 DW_MUTEX_UNLOCK; | |
6769 return retval; | |
6770 } | |
6771 | |
6772 /* | |
6773 * Sets the topmost item in the viewport. | |
6774 * Parameters: | |
6775 * handle: Handle to the listbox to be cleared. | |
6776 * top: Index to the top item. | |
6777 */ | |
6778 void dw_listbox_set_top(HWND handle, int top) | |
6779 { | |
6780 GtkWidget *handle2 = handle; | |
6781 int _locked_by_me = FALSE; | |
6782 | |
6783 DW_MUTEX_LOCK; | |
6784 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
6785 { | |
6786 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
6787 if(tmp) | |
6788 handle2 = tmp; | |
6789 } | |
6790 if(GTK_IS_LIST(handle2)) | |
6791 { | |
6792 int count = dw_listbox_count(handle); | |
6793 GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(handle)); | |
6794 float pos, ratio; | |
6795 | |
6796 if(count) | |
6797 { | |
6798 ratio = (float)top/(float)count; | |
6799 | |
6800 pos = (ratio * (float)(adj->upper - adj->lower)) + adj->lower; | |
6801 | |
6802 gtk_adjustment_set_value(adj, pos); | |
6803 } | |
6804 } | |
6805 DW_MUTEX_UNLOCK; | |
6806 } | |
6807 | |
6808 /* | |
6809 * Copies the given index item's text into buffer. | |
6810 * Parameters: | |
6811 * handle: Handle to the listbox to be queried. | |
6812 * index: Index into the list to be queried. | |
6813 * buffer: Buffer where text will be copied. | |
6814 * length: Length of the buffer (including NULL). | |
6815 */ | |
6816 void dw_listbox_query_text(HWND handle, unsigned int index, char *buffer, unsigned int length) | |
6817 { | |
6818 GtkWidget *handle2 = handle; | |
6819 int _locked_by_me = FALSE; | |
6820 | |
6821 DW_MUTEX_LOCK; | |
6822 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
6823 { | |
6824 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
6825 if(tmp) | |
6826 handle2 = tmp; | |
6827 } | |
6828 else if(GTK_IS_COMBO(handle)) | |
6829 { | |
6830 handle2 = GTK_COMBO(handle)->list; | |
6831 } | |
6832 if(GTK_IS_LIST(handle2)) | |
6833 { | |
6834 int counter = 0; | |
6835 GList *list = GTK_LIST(handle2)->children; | |
6836 | |
6837 while(list) | |
6838 { | |
6839 if(counter == index) | |
6840 { | |
6841 gchar *text = ""; | |
6842 | |
6843 if(GTK_IS_LIST_ITEM(list->data)) | |
6844 { | |
6845 GtkListItem *li = GTK_LIST_ITEM(list->data); | |
6846 | |
6847 if(GTK_IS_ITEM(&(li->item))) | |
6848 { | |
6849 GtkItem *i = &(li->item); | |
6850 | |
6851 if(GTK_IS_BIN(&(i->bin))) | |
6852 { | |
6853 GtkBin *b = &(i->bin); | |
6854 | |
6855 if(GTK_IS_LABEL(b->child)) | |
6856 gtk_label_get(GTK_LABEL(b->child), &text); | |
6857 } | |
6858 } | |
6859 } | |
6860 else if(GTK_IS_COMBO(handle) && list->data) | |
6861 text = (gchar *)list->data; | |
6862 | |
6863 strncpy(buffer, (char *)text, length); | |
6864 break; | |
6865 } | |
6866 list = list->next; | |
6867 counter++; | |
6868 } | |
6869 } | |
6870 DW_MUTEX_UNLOCK; | |
6871 } | |
6872 | |
6873 /* | |
6874 * Sets the text of a given listbox entry. | |
6875 * Parameters: | |
6876 * handle: Handle to the listbox to be queried. | |
6877 * index: Index into the list to be queried. | |
6878 * buffer: Buffer where text will be copied. | |
6879 */ | |
6880 void dw_listbox_set_text(HWND handle, unsigned int index, char *buffer) | |
6881 { | |
6882 GtkWidget *handle2 = handle; | |
6883 int _locked_by_me = FALSE; | |
6884 | |
6885 DW_MUTEX_LOCK; | |
6886 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
6887 { | |
6888 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
6889 if(tmp) | |
6890 handle2 = tmp; | |
6891 } | |
6892 else if(GTK_IS_COMBO(handle)) | |
6893 { | |
6894 handle2 = GTK_COMBO(handle)->list; | |
6895 } | |
6896 if(GTK_IS_LIST(handle2)) | |
6897 { | |
6898 int counter = 0; | |
6899 GList *list = GTK_LIST(handle2)->children; | |
6900 | |
6901 while(list) | |
6902 { | |
6903 if(counter == index) | |
6904 { | |
6905 | |
6906 if(GTK_IS_LIST_ITEM(list->data)) | |
6907 { | |
6908 GtkListItem *li = GTK_LIST_ITEM(list->data); | |
6909 | |
6910 if(GTK_IS_ITEM(&(li->item))) | |
6911 { | |
6912 GtkItem *i = &(li->item); | |
6913 | |
6914 if(GTK_IS_BIN(&(i->bin))) | |
6915 { | |
6916 GtkBin *b = &(i->bin); | |
6917 | |
6918 if(GTK_IS_LABEL(b->child)) | |
6919 gtk_label_set_text(GTK_LABEL(b->child), buffer); | |
6920 } | |
6921 } | |
6922 } | |
6923 else if(GTK_IS_COMBO(handle)) | |
6924 { | |
6925 if(list->data) | |
6926 g_free(list->data); | |
6927 list->data = g_strdup(buffer); | |
6928 } | |
6929 break; | |
6930 } | |
6931 list = list->next; | |
6932 counter++; | |
6933 } | |
6934 } | |
6935 DW_MUTEX_UNLOCK; | |
6936 } | |
6937 | |
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
|
6938 #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
|
6939 /* 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
|
6940 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
|
6941 { |
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
|
6942 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
|
6943 { |
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
|
6944 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
|
6945 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
|
6946 |
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
|
6947 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
|
6948 } |
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
|
6949 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
|
6950 } |
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
|
6951 #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
|
6952 |
3 | 6953 /* |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6954 * 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
|
6955 * Parameters: |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6956 * 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
|
6957 * 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
|
6958 */ |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6959 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
|
6960 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6961 GtkWidget *handle2 = handle; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6962 int retval = DW_LIT_NONE; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6963 int _locked_by_me = FALSE; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6964 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6965 DW_MUTEX_LOCK; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6966 if(GTK_IS_SCROLLED_WINDOW(handle)) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6967 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6968 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
|
6969 if(tmp) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6970 handle2 = tmp; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6971 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6972 if(GTK_IS_LIST(handle2)) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6973 { |
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
|
6974 #if GTK_MAJOR_VERSION > 1 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6975 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
|
6976 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
|
6977 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6978 while(list) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6979 { |
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
|
6980 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
|
6981 |
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
|
6982 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
|
6983 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
|
6984 && 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
|
6985 { |
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
|
6986 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
|
6987 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
|
6988 } |
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
|
6989 |
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
|
6990 |
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
|
6991 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
|
6992 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
|
6993 } |
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
|
6994 #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
|
6995 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
|
6996 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
|
6997 |
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
|
6998 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
|
6999 { |
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
|
7000 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
|
7001 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7002 retval = counter; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7003 break; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7004 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7005 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7006 list = list->next; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7007 counter++; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7008 } |
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
|
7009 #endif |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7010 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7011 DW_MUTEX_UNLOCK; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7012 return retval; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7013 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7014 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7015 /* |
3 | 7016 * Returns the index to the item in the list currently selected. |
7017 * Parameters: | |
7018 * handle: Handle to the listbox to be queried. | |
7019 */ | |
7020 unsigned int dw_listbox_selected(HWND handle) | |
7021 { | |
7022 GtkWidget *handle2 = handle; | |
7023 int retval = DW_LIT_NONE; | |
7024 int _locked_by_me = FALSE; | |
7025 | |
7026 DW_MUTEX_LOCK; | |
7027 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
7028 { | |
7029 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
7030 if(tmp) | |
7031 handle2 = tmp; | |
7032 } | |
7033 else if(GTK_IS_COMBO(handle)) | |
7034 { | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7035 retval = (unsigned int)gtk_object_get_data(GTK_OBJECT(handle), "_dw_item"); |
3 | 7036 DW_MUTEX_UNLOCK; |
7037 return retval; | |
7038 } | |
7039 if(GTK_IS_LIST(handle2)) | |
7040 { | |
7041 int counter = 0; | |
7042 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
|
7043 #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
|
7044 GList *selection = GTK_LIST(handle2)->undo_unselection; |
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
|
7045 #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
|
7046 GList *selection = GTK_LIST(handle2)->selection; |
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 #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
|
7048 if(selection) |
3 | 7049 { |
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
|
7050 while(list) |
3 | 7051 { |
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
|
7052 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
|
7053 { |
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 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
|
7055 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
|
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++; |
3 | 7060 } |
7061 } | |
7062 } | |
7063 DW_MUTEX_UNLOCK; | |
7064 return retval; | |
7065 } | |
7066 | |
7067 /* | |
7068 * Sets the selection state of a given index. | |
7069 * Parameters: | |
7070 * handle: Handle to the listbox to be set. | |
7071 * index: Item index. | |
7072 * state: TRUE if selected FALSE if unselected. | |
7073 */ | |
7074 void dw_listbox_select(HWND handle, int index, int state) | |
7075 { | |
7076 GtkWidget *handle2 = handle; | |
7077 int _locked_by_me = FALSE; | |
7078 | |
7079 DW_MUTEX_LOCK; | |
7080 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
7081 { | |
7082 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
7083 if(tmp) | |
7084 handle2 = tmp; | |
7085 } | |
7086 else if(GTK_IS_COMBO(handle)) | |
7087 { | |
7088 handle2 = GTK_COMBO(handle)->list; | |
7089 } | |
7090 if(GTK_IS_LIST(handle2)) | |
7091 { | |
7092 if(state) | |
7093 gtk_list_select_item(GTK_LIST(handle2), index); | |
7094 else | |
7095 gtk_list_unselect_item(GTK_LIST(handle2), index); | |
7096 } | |
7097 DW_MUTEX_UNLOCK; | |
7098 } | |
7099 | |
7100 /* | |
7101 * Deletes the item with given index from the list. | |
7102 * Parameters: | |
7103 * handle: Handle to the listbox to be set. | |
7104 * index: Item index. | |
7105 */ | |
7106 void dw_listbox_delete(HWND handle, int index) | |
7107 { | |
7108 GtkWidget *handle2 = handle; | |
7109 int _locked_by_me = FALSE; | |
7110 | |
7111 DW_MUTEX_LOCK; | |
7112 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
7113 { | |
7114 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
7115 if(tmp) | |
7116 handle2 = tmp; | |
7117 } | |
7118 else if(GTK_IS_COMBO(handle)) | |
7119 { | |
7120 handle2 = GTK_COMBO(handle)->list; | |
7121 } | |
7122 if(GTK_IS_LIST(handle2)) | |
7123 gtk_list_clear_items(GTK_LIST(handle2), index, index); | |
7124 DW_MUTEX_UNLOCK; | |
7125 } | |
7126 | |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7127 /* 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
|
7128 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
|
7129 { |
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
|
7130 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
|
7131 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
|
7132 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
|
7133 |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7134 /* 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
|
7135 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
|
7136 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
|
7137 |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7138 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
|
7139 |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7140 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
|
7141 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
|
7142 |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7143 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
|
7144 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
|
7145 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
|
7146 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
|
7147 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
|
7148 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
|
7149 } |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7150 |
122
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
7151 #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
|
7152 /* 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
|
7153 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
|
7154 { |
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7155 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
|
7156 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
|
7157 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
|
7158 |
145
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7159 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
|
7160 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
|
7161 |
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
|
7162 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
|
7163 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
|
7164 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
|
7165 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
|
7166 |
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
|
7167 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
|
7168 *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
|
7169 } |
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
|
7170 #endif |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7171 |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7172 /* |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7173 * 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
|
7174 * 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
|
7175 * 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
|
7176 * 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
|
7177 * 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
|
7178 * Returns: |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7179 * 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
|
7180 */ |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7181 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
|
7182 { |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7183 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
|
7184 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
|
7185 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
|
7186 |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7187 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
|
7188 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
|
7189 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
|
7190 else |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7191 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
|
7192 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
|
7193 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
|
7194 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
|
7195 *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
|
7196 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
|
7197 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
|
7198 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
|
7199 #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
|
7200 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
|
7201 #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
|
7202 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
|
7203 #endif |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7204 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
|
7205 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
|
7206 return tmp; |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7207 } |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7208 |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7209 /* |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7210 * 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
|
7211 * Parameters: |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7212 * 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
|
7213 */ |
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
|
7214 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
|
7215 { |
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 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
|
7217 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
|
7218 |
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7219 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
|
7220 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
|
7221 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
|
7222 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
|
7223 |
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
|
7224 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
|
7225 *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
|
7226 |
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7227 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
|
7228 { |
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7229 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
|
7230 |
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7231 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
|
7232 } |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7233 } |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7234 |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7235 /* |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7236 * 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
|
7237 * Parameters: |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7238 * 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
|
7239 */ |
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
|
7240 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
|
7241 { |
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 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
|
7243 |
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 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
|
7245 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
|
7246 return 0.0; |
3 | 7247 } |
7248 | |
7249 /* | |
7250 * Pack windows (widgets) into a box from the start (or top). | |
7251 * Parameters: | |
7252 * box: Window handle of the box to be packed into. | |
7253 * item: Window handle of the item to be back. | |
7254 * width: Width in pixels of the item or -1 to be self determined. | |
7255 * height: Height in pixels of the item or -1 to be self determined. | |
7256 * hsize: TRUE if the window (widget) should expand horizontally to fill space given. | |
7257 * vsize: TRUE if the window (widget) should expand vertically to fill space given. | |
7258 * pad: Number of pixels of padding around the item. | |
7259 */ | |
7260 void dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) | |
7261 { | |
7262 int _locked_by_me = FALSE; | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
7263 GtkWidget *tmp; |
3 | 7264 |
7265 if(!box) | |
7266 return; | |
7267 | |
7268 DW_MUTEX_LOCK; | |
7269 | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7270 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
|
7271 box = tmp; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
7272 |
3 | 7273 if(!item) |
7274 { | |
7275 item = gtk_label_new(""); | |
7276 gtk_widget_show(item); | |
7277 } | |
7278 | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7279 if(GTK_IS_TABLE(box)) |
3 | 7280 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7281 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
|
7282 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
|
7283 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
|
7284 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7285 /* 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
|
7286 * 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
|
7287 * 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
|
7288 * 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
|
7289 */ |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7290 if(GTK_IS_TABLE(item)) |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7291 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7292 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
|
7293 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7294 if(eventbox) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7295 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7296 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
|
7297 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
|
7298 item = eventbox; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7299 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7300 } |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7301 |
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
|
7302 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
|
7303 { |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7304 x = 0; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7305 y = boxcount; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7306 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
|
7307 } |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7308 else |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7309 { |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7310 x = boxcount; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7311 y = 0; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7312 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
|
7313 } |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7314 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7315 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
|
7316 gtk_object_set_data(GTK_OBJECT(box), "_dw_boxcount", (gpointer)boxcount + 1); |
3 | 7317 gtk_widget_set_usize(item, width, height); |
7318 if(GTK_IS_RADIO_BUTTON(item)) | |
7319 { | |
7320 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
|
7321 GtkWidget *groupstart = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(box), "_dw_group"); |
3 | 7322 |
7323 if(groupstart) | |
7324 { | |
7325 group = gtk_radio_button_group(GTK_RADIO_BUTTON(groupstart)); | |
7326 gtk_radio_button_set_group(GTK_RADIO_BUTTON(item), group); | |
7327 } | |
7328 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
|
7329 gtk_object_set_data(GTK_OBJECT(box), "_dw_group", (gpointer)item); |
3 | 7330 } |
7331 } | |
7332 else | |
7333 { | |
7334 GtkWidget *vbox = gtk_vbox_new(FALSE, 0); | |
7335 | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7336 if(GTK_IS_TABLE(item)) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7337 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7338 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
|
7339 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7340 if(eventbox) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7341 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7342 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
|
7343 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
|
7344 item = eventbox; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7345 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7346 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7347 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7348 gtk_container_border_width(GTK_CONTAINER(box), pad); |
3 | 7349 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
|
7350 gtk_box_pack_end(GTK_BOX(vbox), item, TRUE, TRUE, 0); |
3 | 7351 gtk_widget_show(vbox); |
7352 | |
7353 gtk_widget_set_usize(item, width, height); | |
7354 gtk_object_set_user_data(GTK_OBJECT(box), vbox); | |
7355 } | |
7356 DW_MUTEX_UNLOCK; | |
7357 } | |
7358 | |
7359 /* | |
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
|
7360 * 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
|
7361 * 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
|
7362 * 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
|
7363 * 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
|
7364 */ |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
7365 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
|
7366 { |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
7367 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
|
7368 |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
7369 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
|
7370 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
|
7371 |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
7372 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
|
7373 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
|
7374 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
|
7375 } |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
7376 |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
7377 /* |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7378 * 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
|
7379 * Parameters: |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7380 * 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
|
7381 * 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
|
7382 */ |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7383 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
|
7384 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7385 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
|
7386 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7387 if(!window) |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7388 return; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7389 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7390 DW_MUTEX_LOCK; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7391 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
|
7392 DW_MUTEX_UNLOCK; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7393 } |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7394 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7395 /* |
3 | 7396 * Returns some information about the current operating environment. |
7397 * Parameters: | |
7398 * env: Pointer to a DWEnv struct. | |
7399 */ | |
7400 void dw_environment_query(DWEnv *env) | |
7401 { | |
7402 struct utsname name; | |
7403 char tempbuf[100]; | |
7404 int len, z; | |
7405 | |
7406 uname(&name); | |
7407 strcpy(env->osName, name.sysname); | |
7408 strcpy(tempbuf, name.release); | |
7409 | |
7410 env->MajorBuild = env->MinorBuild = 0; | |
7411 | |
7412 len = strlen(tempbuf); | |
7413 | |
15
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
7414 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
|
7415 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
|
7416 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
|
7417 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
|
7418 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
|
7419 |
3 | 7420 for(z=1;z<len;z++) |
7421 { | |
7422 if(tempbuf[z] == '.') | |
7423 { | |
7424 tempbuf[z] = '\0'; | |
7425 env->MajorVersion = atoi(&tempbuf[z-1]); | |
7426 env->MinorVersion = atoi(&tempbuf[z+1]); | |
7427 return; | |
7428 } | |
7429 } | |
7430 env->MajorVersion = atoi(tempbuf); | |
7431 env->MinorVersion = 0; | |
7432 } | |
7433 | |
7434 /* 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
|
7435 static gint _gtk_file_ok(GtkWidget *widget, DWDialog *dwwait) |
3 | 7436 { |
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
|
7437 #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
|
7438 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
|
7439 #else |
3 | 7440 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
|
7441 #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
|
7442 char *tmpdup=NULL; |
3 | 7443 |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
7444 if(!dwwait) |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
7445 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
|
7446 |
214
0e98514a3905
Applied patch from Mark Hessling to prevent the return buffer from the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
208
diff
changeset
|
7447 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
|
7448 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
|
7449 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
|
7450 _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
|
7451 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
|
7452 return FALSE; |
3 | 7453 } |
7454 | |
7455 /* 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
|
7456 static gint _gtk_file_cancel(GtkWidget *widget, DWDialog *dwwait) |
3 | 7457 { |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
7458 if(!dwwait) |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
7459 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
|
7460 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
7461 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
|
7462 _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
|
7463 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
|
7464 return FALSE; |
3 | 7465 } |
7466 | |
7467 /* | |
7468 * Opens a file dialog and queries user selection. | |
7469 * Parameters: | |
7470 * title: Title bar text for dialog. | |
7471 * defpath: The default path of the open dialog. | |
7472 * ext: Default file extention. | |
7473 * flags: DW_FILE_OPEN or DW_FILE_SAVE. | |
7474 * Returns: | |
7475 * NULL on error. A malloced buffer containing | |
7476 * the file path on success. | |
7477 * | |
7478 */ | |
7479 char *dw_file_browse(char *title, char *defpath, char *ext, int flags) | |
7480 { | |
7481 GtkWidget *filew; | |
7482 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
|
7483 DWDialog *dwwait; |
3 | 7484 |
7485 DW_MUTEX_LOCK; | |
7486 | |
7487 /* The DW mutex should be sufficient for | |
7488 * insuring no thread changes this unknowingly. | |
7489 */ | |
7490 if(_dw_file_active) | |
7491 { | |
7492 DW_MUTEX_UNLOCK; | |
7493 return NULL; | |
7494 } | |
7495 | |
7496 _dw_file_active = 1; | |
7497 | |
7498 filew = gtk_file_selection_new(title); | |
7499 | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
7500 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
|
7501 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
7502 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
|
7503 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filew)->cancel_button), "clicked", (GtkSignalFunc) _gtk_file_cancel, dwwait); |
3 | 7504 |
7505 if(defpath) | |
7506 gtk_file_selection_set_filename(GTK_FILE_SELECTION(filew), defpath); | |
7507 | |
7508 gtk_widget_show(filew); | |
7509 | |
7510 DW_MUTEX_UNLOCK; | |
7511 | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
7512 return (char *)dw_dialog_wait(dwwait); |
3 | 7513 } |
7514 | |
7515 | |
7516 /* | |
7517 * Execute and external program in a seperate session. | |
7518 * Parameters: | |
7519 * program: Program name with optional path. | |
7520 * type: Either DW_EXEC_CON or DW_EXEC_GUI. | |
7521 * params: An array of pointers to string arguements. | |
7522 * Returns: | |
7523 * -1 on error. | |
7524 */ | |
7525 int dw_exec(char *program, int type, char **params) | |
7526 { | |
7527 int ret = -1; | |
7528 | |
7529 if((ret = fork()) == 0) | |
7530 { | |
7531 int i; | |
7532 | |
7533 for (i = 3; i < 256; i++) | |
7534 close(i); | |
7535 setsid(); | |
7536 if(type == DW_EXEC_GUI) | |
7537 { | |
7538 execvp(program, params); | |
7539 } | |
7540 else if(type == DW_EXEC_CON) | |
7541 { | |
7542 char **tmpargs; | |
7543 | |
7544 if(!params) | |
7545 { | |
7546 tmpargs = malloc(sizeof(char *)); | |
7547 tmpargs[0] = NULL; | |
7548 } | |
7549 else | |
7550 { | |
7551 int z = 0; | |
7552 | |
7553 while(params[z]) | |
7554 { | |
7555 z++; | |
7556 } | |
7557 tmpargs = malloc(sizeof(char *)*(z+3)); | |
7558 z=0; | |
7559 tmpargs[0] = "xterm"; | |
7560 tmpargs[1] = "-e"; | |
7561 while(params[z]) | |
7562 { | |
7563 tmpargs[z+2] = params[z]; | |
7564 z++; | |
7565 } | |
7566 tmpargs[z+2] = NULL; | |
7567 } | |
7568 execvp("xterm", tmpargs); | |
7569 free(tmpargs); | |
7570 } | |
7571 /* If we got here exec failed */ | |
7572 _exit(-1); | |
7573 } | |
7574 return ret; | |
7575 } | |
7576 | |
7577 /* | |
7578 * Loads a web browser pointed at the given URL. | |
7579 * Parameters: | |
7580 * url: Uniform resource locator. | |
7581 */ | |
7582 int dw_browse(char *url) | |
7583 { | |
7584 /* Is there a way to find the webbrowser in Unix? */ | |
7585 char *execargs[3], *browser = "netscape"; | |
7586 | |
7587 execargs[0] = browser; | |
7588 execargs[1] = url; | |
7589 execargs[2] = NULL; | |
7590 | |
7591 return dw_exec(browser, DW_EXEC_GUI, execargs); | |
7592 } | |
7593 | |
7594 /* | |
7595 * Returns a pointer to a static buffer which containes the | |
7596 * current user directory. Or the root directory (C:\ on | |
7597 * OS/2 and Windows). | |
7598 */ | |
7599 char *dw_user_dir(void) | |
7600 { | |
7601 static char _user_dir[1024] = ""; | |
7602 | |
7603 if(!_user_dir[0]) | |
7604 { | |
7605 char *home = getenv("HOME"); | |
7606 | |
7607 if(home) | |
7608 strcpy(_user_dir, home); | |
7609 else | |
7610 strcpy(_user_dir, "/"); | |
7611 } | |
7612 return _user_dir; | |
7613 } | |
7614 | |
7615 /* | |
7616 * Call a function from the window (widget)'s context. | |
7617 * Parameters: | |
7618 * handle: Window handle of the widget. | |
7619 * function: Function pointer to be called. | |
7620 * data: Pointer to the data to be passed to the function. | |
7621 */ | |
7622 void dw_window_function(HWND handle, void *function, void *data) | |
7623 { | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
7624 void (* windowfunc)(void *); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
7625 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
7626 windowfunc = function; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
7627 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
7628 if(windowfunc) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
7629 windowfunc(data); |
3 | 7630 } |
7631 | |
90
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7632 /* |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7633 * 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
|
7634 * Parameters: |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7635 * 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
|
7636 * 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
|
7637 * 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
|
7638 */ |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7639 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
|
7640 { |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7641 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
|
7642 |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7643 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
|
7644 return; |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7645 |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7646 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
|
7647 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
|
7648 { |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
7649 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
|
7650 { |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
7651 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
|
7652 |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
7653 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
|
7654 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
|
7655 } |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
7656 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
|
7657 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
|
7658 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
|
7659 } |
90
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7660 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
|
7661 } |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7662 |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7663 /* |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7664 * 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
|
7665 * Parameters: |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7666 * 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
|
7667 * 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
|
7668 * 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
|
7669 */ |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7670 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
|
7671 { |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7672 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
|
7673 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
|
7674 |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7675 if(!window) |
92
0a085f295e81
A couple more minor changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
91
diff
changeset
|
7676 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
|
7677 |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7678 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
|
7679 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
|
7680 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
|
7681 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
|
7682 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
|
7683 } |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7684 |
3 | 7685 /* |
195
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7686 * 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
|
7687 * Parameters: |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7688 * 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
|
7689 * 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
|
7690 * 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
|
7691 * Returns: |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7692 * 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
|
7693 */ |
199
b955228477b3
Removed the window parameter to dw_timer_connect() it was no needed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
198
diff
changeset
|
7694 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
|
7695 { |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7696 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
|
7697 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7698 DW_MUTEX_LOCK; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7699 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
|
7700 DW_MUTEX_UNLOCK; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7701 return tag; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7702 } |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7703 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7704 /* |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7705 * Removes timer callback. |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7706 * Parameters: |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7707 * 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
|
7708 */ |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7709 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
|
7710 { |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7711 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
|
7712 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7713 DW_MUTEX_LOCK; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7714 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
|
7715 DW_MUTEX_UNLOCK; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7716 } |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7717 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7718 /* |
3 | 7719 * Add a callback to a window event. |
7720 * Parameters: | |
7721 * window: Window handle of signal to be called back. | |
7722 * signame: A string pointer identifying which signal to be hooked. | |
7723 * sigfunc: The pointer to the function to be used as the callback. | |
7724 * data: User data to be passed to the handler function. | |
7725 */ | |
7726 void dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data) | |
7727 { | |
7728 void *thisfunc = _findsigfunc(signame); | |
7729 char *thisname = signame; | |
7730 HWND thiswindow = window; | |
7731 int _locked_by_me = FALSE; | |
7732 | |
7733 DW_MUTEX_LOCK; | |
7734 if(GTK_IS_SCROLLED_WINDOW(thiswindow)) | |
7735 { | |
7736 thiswindow = (HWND)gtk_object_get_user_data(GTK_OBJECT(window)); | |
7737 } | |
7738 | |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7739 if(GTK_IS_MENU_ITEM(thiswindow) && strcmp(signame, DW_SIGNAL_CLICKED) == 0) |
3 | 7740 { |
7741 thisname = "activate"; | |
7742 thisfunc = _findsigfunc(thisname); | |
7743 } | |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7744 else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_CONTEXT) == 0) |
3 | 7745 { |
7746 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
|
7747 thisfunc = _findsigfunc(DW_SIGNAL_ITEM_CONTEXT); |
3 | 7748 } |
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
|
7749 #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
|
7750 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
|
7751 { |
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
|
7752 thisfunc = _findsigfunc("tree-context"); |
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
|
7753 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
7754 gtk_signal_connect(GTK_OBJECT(thiswindow), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
7755 (gpointer)_set_signal_handler(thiswindow, window, sigfunc, data)); |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
7756 gtk_signal_connect(GTK_OBJECT(window), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
7757 (gpointer)_set_signal_handler(window, window, sigfunc, 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
|
7758 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
|
7759 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
|
7760 } |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7761 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
|
7762 { |
362
eb61b854fd58
Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
361
diff
changeset
|
7763 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
|
7764 |
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
|
7765 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
|
7766 thisname = "changed"; |
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
|
7767 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
7768 g_signal_connect(G_OBJECT(thiswindow), thisname, (GCallback)thisfunc, |
362
eb61b854fd58
Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
361
diff
changeset
|
7769 (gpointer)_set_signal_handler(treeview, window, sigfunc, 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
|
7770 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
|
7771 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
|
7772 } |
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
|
7773 #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
|
7774 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
|
7775 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
7776 int counter = (int)_set_signal_handler(thiswindow, window, sigfunc, data); |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
7777 |
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
|
7778 thisfunc = _findsigfunc("tree-context"); |
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
|
7779 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7780 gtk_object_set_data(GTK_OBJECT(thiswindow), "_dw_container_context_func", (gpointer)thisfunc); |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
7781 gtk_object_set_data(GTK_OBJECT(thiswindow), "_dw_container_context_data", (gpointer)counter); |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
7782 gtk_signal_connect(GTK_OBJECT(thiswindow), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), (gpointer)counter); |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
7783 gtk_signal_connect(GTK_OBJECT(window), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
7784 (gpointer)_set_signal_handler(window, window, sigfunc, 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
|
7785 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
|
7786 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
|
7787 } |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7788 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
|
7789 { |
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
|
7790 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
|
7791 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7792 gtk_object_set_data(GTK_OBJECT(thiswindow), "_dw_select_child_func", (gpointer)thisfunc); |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
7793 gtk_object_set_data(GTK_OBJECT(thiswindow), "_dw_select_child_data", |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
7794 (gpointer)_set_signal_handler(thiswindow, window, sigfunc, 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
|
7795 } |
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
|
7796 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
|
7797 } |
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
|
7798 #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
|
7799 else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_ENTER) == 0) |
3 | 7800 { |
364
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
7801 gtk_signal_connect(GTK_OBJECT(thiswindow), "key_press_event", GTK_SIGNAL_FUNC(_container_enter_event), |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
7802 (gpointer)_set_signal_handler(thiswindow, window, sigfunc, data)); |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
7803 |
3 | 7804 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
|
7805 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
|
7806 } |
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7807 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
|
7808 { |
d35771f70bdd
Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
163
diff
changeset
|
7809 thisname = "select_row"; |
d35771f70bdd
Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
163
diff
changeset
|
7810 thisfunc = (void *)_container_select_row; |
d35771f70bdd
Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
163
diff
changeset
|
7811 } |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7812 else if(GTK_IS_COMBO(thiswindow) && strcmp(signame, DW_SIGNAL_LIST_SELECT) == 0) |
3 | 7813 { |
7814 thisname = "select_child"; | |
7815 thiswindow = GTK_COMBO(thiswindow)->list; | |
7816 } | |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7817 else if(GTK_IS_LIST(thiswindow) && strcmp(signame, DW_SIGNAL_LIST_SELECT) == 0) |
3 | 7818 { |
7819 thisname = "select_child"; | |
7820 } | |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7821 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
|
7822 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
7823 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
|
7824 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
|
7825 thiswindow = GTK_COMBO(thiswindow)->entry; |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
7826 } |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7827 #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
|
7828 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
|
7829 { |
b6948eac375a
Sync with the latest dynamic windows, tree fixes, and other miscellaneous
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
54
diff
changeset
|
7830 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
|
7831 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
|
7832 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
|
7833 } |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7834 #endif |
205
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
7835 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
|
7836 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
|
7837 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7838 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
|
7839 } |
331
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
7840 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
|
7841 { |
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
7842 thisname = "switch-page"; |
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
7843 } |
3 | 7844 |
7845 if(!thisfunc || !thiswindow) | |
7846 { | |
7847 DW_MUTEX_UNLOCK; | |
7848 return; | |
7849 } | |
7850 | |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
7851 gtk_signal_connect(GTK_OBJECT(thiswindow), thisname, GTK_SIGNAL_FUNC(thisfunc), |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
7852 (gpointer)_set_signal_handler(thiswindow, window, sigfunc, data)); |
3 | 7853 DW_MUTEX_UNLOCK; |
7854 } | |
7855 | |
7856 /* | |
7857 * Removes callbacks for a given window with given name. | |
7858 * Parameters: | |
7859 * window: Window handle of callback to be removed. | |
7860 */ | |
7861 void dw_signal_disconnect_by_name(HWND window, char *signame) | |
7862 { | |
7863 #if 0 | |
7864 gtk_signal_disconnect_by_name(window, signame); | |
7865 #endif | |
7866 } | |
7867 | |
7868 /* | |
7869 * Removes all callbacks for a given window. | |
7870 * Parameters: | |
7871 * window: Window handle of callback to be removed. | |
7872 */ | |
7873 void dw_signal_disconnect_by_window(HWND window) | |
7874 { | |
7875 #if 0 | |
7876 gtk_signal_disconnect_by_window(window); | |
7877 #endif | |
7878 } | |
7879 | |
7880 /* | |
7881 * Removes all callbacks for a given window with specified data. | |
7882 * Parameters: | |
7883 * window: Window handle of callback to be removed. | |
7884 * data: Pointer to the data to be compared against. | |
7885 */ | |
7886 void dw_signal_disconnect_by_data(HWND window, void *data) | |
7887 { | |
7888 dw_signal_disconnect_by_data(window, data); | |
7889 } | |
153
a371875d5486
Sync up with the latest F/X sources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
151
diff
changeset
|
7890 |