Mercurial > dwindows
annotate gtk/dw.c @ 407:a8124a9561c7
Fix for dw_window_set_text() on GTK 2.x.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 11 May 2003 06:10:14 +0000 |
parents | 6a3ef130962f |
children | 1d7be77cbfb5 |
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. | |
407
a8124a9561c7
Fix for dw_window_set_text() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
403
diff
changeset
|
2813 * text: The text associsated with a given window. f |
3 | 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 { |
407
a8124a9561c7
Fix for dw_window_set_text() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
403
diff
changeset
|
2828 #if GTK_MAJOR_VERSION < 2 |
403
6a3ef130962f
Check that the child is actually a label before trying to operate on it.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
402
diff
changeset
|
2829 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
|
2830 |
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 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
|
2832 gtk_label_set_text(GTK_LABEL(label), text); |
407
a8124a9561c7
Fix for dw_window_set_text() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
403
diff
changeset
|
2833 #else |
a8124a9561c7
Fix for dw_window_set_text() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
403
diff
changeset
|
2834 gtk_button_set_label(GTK_BUTTON(handle), text); |
a8124a9561c7
Fix for dw_window_set_text() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
403
diff
changeset
|
2835 #endif |
403
6a3ef130962f
Check that the child is actually a label before trying to operate on it.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
402
diff
changeset
|
2836 } |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2837 else if(GTK_IS_FRAME(handle)) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2838 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2839 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
|
2840 if(tmp && GTK_IS_LABEL(tmp)) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2841 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
|
2842 } |
3 | 2843 DW_MUTEX_UNLOCK; |
2844 } | |
2845 | |
2846 /* | |
2847 * Gets the text used for a given window. | |
2848 * Parameters: | |
2849 * handle: Handle to the window. | |
2850 * Returns: | |
2851 * text: The text associsated with a given window. | |
2852 */ | |
2853 char *dw_window_get_text(HWND handle) | |
2854 { | |
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 #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
|
2856 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
|
2857 #else |
3 | 2858 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
|
2859 #endif |
3 | 2860 int _locked_by_me = FALSE; |
2861 | |
2862 DW_MUTEX_LOCK; | |
2863 if(GTK_IS_ENTRY(handle)) | |
2864 possible = gtk_entry_get_text(GTK_ENTRY(handle)); | |
2865 else if(GTK_IS_COMBO(handle)) | |
2866 possible = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(handle)->entry)); | |
2867 | |
2868 DW_MUTEX_UNLOCK; | |
2869 return strdup(possible); | |
2870 } | |
2871 | |
2872 /* | |
2873 * Disables given window (widget). | |
2874 * Parameters: | |
2875 * handle: Handle to the window. | |
2876 */ | |
2877 void dw_window_disable(HWND handle) | |
2878 { | |
2879 int _locked_by_me = FALSE; | |
2880 | |
2881 DW_MUTEX_LOCK; | |
2882 gtk_widget_set_sensitive(handle, FALSE); | |
2883 DW_MUTEX_UNLOCK; | |
2884 } | |
2885 | |
2886 /* | |
2887 * Enables given window (widget). | |
2888 * Parameters: | |
2889 * handle: Handle to the window. | |
2890 */ | |
2891 void dw_window_enable(HWND handle) | |
2892 { | |
2893 int _locked_by_me = FALSE; | |
2894 | |
2895 DW_MUTEX_LOCK; | |
2896 gtk_widget_set_sensitive(handle, TRUE); | |
2897 DW_MUTEX_UNLOCK; | |
2898 } | |
2899 | |
249
5a594058687f
Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
246
diff
changeset
|
2900 /* |
5a594058687f
Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
246
diff
changeset
|
2901 * 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
|
2902 * Parameters: |
5a594058687f
Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
246
diff
changeset
|
2903 * 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
|
2904 * 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
|
2905 */ |
5a594058687f
Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
246
diff
changeset
|
2906 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
|
2907 { |
267
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2908 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
|
2909 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
|
2910 |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2911 DW_MUTEX_LOCK; |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2912 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
|
2913 { |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2914 #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
|
2915 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
|
2916 #else |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2917 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
|
2918 #endif |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2919 } |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2920 while(list) |
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 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
|
2923 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2924 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
|
2925 { |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2926 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
|
2927 g_list_free(orig); |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2928 DW_MUTEX_UNLOCK; |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2929 return ret; |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2930 } |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2931 } |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2932 list = list->next; |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2933 } |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2934 if(orig) |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2935 g_list_free(orig); |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2936 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
|
2937 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
|
2938 } |
5a594058687f
Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
246
diff
changeset
|
2939 |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2940 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
|
2941 { |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2942 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
|
2943 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2944 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
|
2945 { |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2946 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
|
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] = src[z]; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2949 x++; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2950 } |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2951 } |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2952 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
|
2953 } |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2954 |
3 | 2955 /* |
2956 * Adds text to an MLE box and returns the current point. | |
2957 * Parameters: | |
2958 * handle: Handle to the MLE to be queried. | |
2959 * buffer: Text buffer to be imported. | |
2960 * startpoint: Point to start entering text. | |
2961 */ | |
2962 unsigned int dw_mle_import(HWND handle, char *buffer, int startpoint) | |
2963 { | |
2964 unsigned int tmppoint = startpoint; | |
2965 int _locked_by_me = FALSE; | |
2966 | |
2967 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
|
2968 #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
|
2969 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
|
2970 #else |
3 | 2971 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
|
2972 #endif |
3 | 2973 { |
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
|
2974 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 2975 |
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
|
2976 #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
|
2977 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
|
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 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
|
2980 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
|
2981 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
|
2982 |
7d2108cbcd3e
Porting DW 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 _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
|
2984 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2985 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
|
2986 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
|
2987 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
|
2988 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
|
2989 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
|
2990 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
|
2991 } |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2992 #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
|
2993 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
|
2994 |
3 | 2995 if(tmp && GTK_IS_TEXT(tmp)) |
2996 { | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2997 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
|
2998 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
|
2999 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
|
3000 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
3001 _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
|
3002 |
3 | 3003 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
|
3004 gtk_text_insert(GTK_TEXT(tmp), font, fore, back, impbuf, -1); |
3 | 3005 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
|
3006 free(impbuf); |
3 | 3007 } |
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
|
3008 #endif |
3 | 3009 } |
3010 DW_MUTEX_UNLOCK; | |
3011 return tmppoint; | |
3012 } | |
3013 | |
3014 /* | |
3015 * Grabs text from an MLE box. | |
3016 * Parameters: | |
3017 * handle: Handle to the MLE to be queried. | |
3018 * buffer: Text buffer to be exported. | |
3019 * startpoint: Point to start grabbing text. | |
3020 * length: Amount of text to be grabbed. | |
3021 */ | |
3022 void dw_mle_export(HWND handle, char *buffer, int startpoint, int length) | |
3023 { | |
3024 int _locked_by_me = FALSE; | |
3025 gchar *text; | |
3026 | |
3027 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
|
3028 #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
|
3029 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
|
3030 #else |
3 | 3031 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
|
3032 #endif |
3 | 3033 { |
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
|
3034 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 3035 |
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
|
3036 #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
|
3037 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
|
3038 { |
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 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
|
3040 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
|
3041 |
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 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
|
3043 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
|
3044 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
|
3045 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
|
3046 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
|
3047 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
|
3048 } |
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
|
3049 #else |
3 | 3050 if(tmp && GTK_IS_TEXT(tmp)) |
3051 { | |
3052 text = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), startpoint, startpoint + length); | |
3053 if(text) | |
3054 { | |
3055 strcpy(buffer, text); | |
3056 g_free(text); | |
3057 } | |
3058 } | |
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
|
3059 #endif |
3 | 3060 } |
3061 DW_MUTEX_UNLOCK; | |
3062 } | |
3063 | |
3064 /* | |
3065 * Obtains information about an MLE box. | |
3066 * Parameters: | |
3067 * handle: Handle to the MLE to be queried. | |
3068 * bytes: A pointer to a variable to return the total bytes. | |
3069 * lines: A pointer to a variable to return the number of lines. | |
3070 */ | |
3071 void dw_mle_query(HWND handle, unsigned long *bytes, unsigned long *lines) | |
3072 { | |
3073 int _locked_by_me = FALSE; | |
3074 | |
3075 if(bytes) | |
3076 *bytes = 0; | |
3077 if(lines) | |
3078 *lines = 0; | |
3079 | |
3080 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
|
3081 #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
|
3082 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
|
3083 { |
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
|
3084 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
|
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(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
|
3087 { |
7d2108cbcd3e
Porting DW 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 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
|
3089 |
7d2108cbcd3e
Porting DW 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 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
|
3091 *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
|
3092 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
|
3093 *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
|
3094 } |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3095 } |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3096 #else |
3 | 3097 if(GTK_IS_BOX(handle)) |
3098 { | |
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
|
3099 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 3100 |
3101 if(tmp && GTK_IS_TEXT(tmp)) | |
3102 { | |
3103 if(bytes) | |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3104 *bytes = gtk_text_get_length(GTK_TEXT(tmp)) + 1; |
3 | 3105 if(lines) |
3106 { | |
3107 gchar *text; | |
3108 | |
3109 *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
|
3110 text = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), 0, gtk_text_get_length(GTK_TEXT(tmp))); |
3 | 3111 |
3112 if(text) | |
3113 { | |
3114 int z, len = strlen(text); | |
3115 | |
3116 for(z=0;z<len;z++) | |
3117 { | |
3118 if(text[z] == '\n') | |
3119 (*lines)++; | |
3120 } | |
3121 g_free(text); | |
3122 } | |
3123 } | |
3124 } | |
3125 } | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3126 #endif |
3 | 3127 DW_MUTEX_UNLOCK; |
3128 } | |
3129 | |
3130 /* | |
3131 * Deletes text from an MLE box. | |
3132 * Parameters: | |
3133 * handle: Handle to the MLE to be deleted from. | |
3134 * startpoint: Point to start deleting text. | |
3135 * length: Amount of text to be deleted. | |
3136 */ | |
3137 void dw_mle_delete(HWND handle, int startpoint, int length) | |
3138 { | |
3139 int _locked_by_me = FALSE; | |
3140 | |
3141 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
|
3142 #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
|
3143 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
|
3144 #else |
3 | 3145 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
|
3146 #endif |
3 | 3147 { |
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
|
3148 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 3149 |
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
|
3150 #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
|
3151 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
|
3152 { |
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 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
|
3154 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
|
3155 |
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 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
|
3157 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
|
3158 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
|
3159 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
|
3160 } |
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
|
3161 #else |
3 | 3162 if(tmp && GTK_IS_TEXT(tmp)) |
3163 { | |
3164 gtk_text_set_point(GTK_TEXT(tmp), startpoint); | |
3165 gtk_text_forward_delete(GTK_TEXT(tmp), length); | |
3166 } | |
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
|
3167 #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
|
3168 } |
3 | 3169 DW_MUTEX_UNLOCK; |
3170 } | |
3171 | |
3172 /* | |
3173 * Clears all text from an MLE box. | |
3174 * Parameters: | |
3175 * handle: Handle to the MLE to be cleared. | |
3176 */ | |
3177 void dw_mle_clear(HWND handle) | |
3178 { | |
3179 int length, _locked_by_me = FALSE; | |
3180 | |
3181 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
|
3182 #if GTK_MAJOR_VERSION > 1 |
122
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3183 if(GTK_IS_SCROLLED_WINDOW(handle)) |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3184 { |
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
|
3185 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
|
3186 |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3187 if(tmp && GTK_IS_TEXT_VIEW(tmp)) |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3188 { |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3189 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
|
3190 |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3191 length = -1; |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3192 gtk_text_buffer_set_text(buffer, "", length); |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3193 } |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3194 } |
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
|
3195 #else |
3 | 3196 if(GTK_IS_BOX(handle)) |
3197 { | |
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
|
3198 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 3199 |
3200 if(tmp && GTK_IS_TEXT(tmp)) | |
3201 { | |
3202 length = gtk_text_get_length(GTK_TEXT(tmp)); | |
3203 gtk_text_set_point(GTK_TEXT(tmp), 0); | |
3204 gtk_text_forward_delete(GTK_TEXT(tmp), length); | |
3205 } | |
3206 } | |
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
|
3207 #endif |
3 | 3208 DW_MUTEX_UNLOCK; |
3209 } | |
3210 | |
3211 /* | |
3212 * Sets the visible line of an MLE box. | |
3213 * Parameters: | |
3214 * handle: Handle to the MLE. | |
3215 * line: Line to be visible. | |
3216 */ | |
3217 void dw_mle_set_visible(HWND handle, int line) | |
3218 { | |
3219 int _locked_by_me = FALSE; | |
3220 | |
3221 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
|
3222 #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
|
3223 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
|
3224 { |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3225 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
|
3226 |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3227 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
|
3228 { |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3229 GtkTextBuffer *tbuffer; |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3230 GtkTextIter iter; |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3231 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
|
3232 |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3233 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
|
3234 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
|
3235 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
|
3236 if(!mark) |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3237 { |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3238 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
|
3239 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
|
3240 } |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3241 else |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3242 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
|
3243 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
|
3244 0, FALSE, 0, 0); |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3245 } |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3246 } |
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
|
3247 #else |
3 | 3248 if(GTK_IS_BOX(handle)) |
3249 { | |
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
|
3250 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 3251 |
3252 if(tmp && GTK_IS_TEXT(tmp)) | |
3253 { | |
3254 unsigned long lines; | |
3255 float pos, ratio; | |
3256 | |
3257 dw_mle_query(handle, NULL, &lines); | |
3258 | |
3259 if(lines) | |
3260 { | |
3261 ratio = (float)line/(float)lines; | |
3262 | |
3263 pos = (ratio * (float)(GTK_TEXT(tmp)->vadj->upper - GTK_TEXT(tmp)->vadj->lower)) + GTK_TEXT(tmp)->vadj->lower; | |
3264 | |
3265 gtk_adjustment_set_value(GTK_TEXT(tmp)->vadj, pos); | |
3266 } | |
3267 } | |
3268 } | |
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
|
3269 #endif |
3 | 3270 DW_MUTEX_UNLOCK; |
3271 } | |
3272 | |
3273 /* | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3274 * Sets the editablity of an MLE box. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3275 * Parameters: |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3276 * handle: Handle to the MLE. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3277 * 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
|
3278 */ |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3279 void dw_mle_set_editable(HWND handle, int state) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3280 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3281 int _locked_by_me = FALSE; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3282 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3283 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
|
3284 #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
|
3285 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
|
3286 { |
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
|
3287 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
|
3288 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3289 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
|
3290 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
|
3291 } |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3292 #else |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3293 if(GTK_IS_BOX(handle)) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3294 { |
147
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
3295 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3296 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3297 if(tmp && GTK_IS_TEXT(tmp)) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3298 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
|
3299 } |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3300 #endif |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3301 DW_MUTEX_UNLOCK; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3302 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3303 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3304 /* |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3305 * Sets the word wrap state of an MLE box. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3306 * Parameters: |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3307 * handle: Handle to the MLE. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3308 * 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
|
3309 */ |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3310 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
|
3311 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3312 int _locked_by_me = FALSE; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3313 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3314 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
|
3315 #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
|
3316 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
|
3317 { |
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
|
3318 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
|
3319 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3320 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
|
3321 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
|
3322 } |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3323 #else |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3324 if(GTK_IS_BOX(handle)) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3325 { |
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
|
3326 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
|
3327 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3328 if(tmp && GTK_IS_TEXT(tmp)) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3329 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3330 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
|
3331 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
|
3332 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3333 } |
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
|
3334 #endif |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3335 DW_MUTEX_UNLOCK; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3336 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3337 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3338 /* |
3 | 3339 * Sets the current cursor position of an MLE box. |
3340 * Parameters: | |
3341 * handle: Handle to the MLE to be positioned. | |
3342 * point: Point to position cursor. | |
3343 */ | |
3344 void dw_mle_set(HWND handle, int point) | |
3345 { | |
3346 int _locked_by_me = FALSE; | |
3347 | |
3348 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
|
3349 #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
|
3350 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
|
3351 #else |
3 | 3352 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
|
3353 #endif |
3 | 3354 { |
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
|
3355 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 3356 |
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
|
3357 #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
|
3358 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
|
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 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
|
3361 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
|
3362 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
|
3363 |
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
|
3364 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
|
3365 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
|
3366 if(!mark) |
08e56a0f9541
dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
352
diff
changeset
|
3367 { |
08e56a0f9541
dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
352
diff
changeset
|
3368 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
|
3369 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
|
3370 } |
08e56a0f9541
dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
352
diff
changeset
|
3371 else |
08e56a0f9541
dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
352
diff
changeset
|
3372 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
|
3373 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
|
3374 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
|
3375 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
|
3376 } |
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
|
3377 #else |
3 | 3378 if(tmp && GTK_IS_TEXT(tmp)) |
3379 { | |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3380 unsigned long chars; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3381 float pos, ratio; |
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 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
|
3384 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3385 if(chars) |
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 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
|
3388 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3389 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
|
3390 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3391 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
|
3392 } |
3 | 3393 gtk_text_set_point(GTK_TEXT(tmp), point); |
3394 } | |
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
|
3395 #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
|
3396 } |
3 | 3397 DW_MUTEX_UNLOCK; |
3398 } | |
3399 | |
3400 /* | |
3401 * Finds text in an MLE box. | |
3402 * Parameters: | |
3403 * handle: Handle to the MLE to be cleared. | |
3404 * text: Text to search for. | |
3405 * point: Start point of search. | |
3406 * flags: Search specific flags. | |
3407 */ | |
3408 int dw_mle_search(HWND handle, char *text, int point, unsigned long flags) | |
3409 { | |
3410 int _locked_by_me = FALSE, retval = 0; | |
3411 | |
3412 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
|
3413 #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
|
3414 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
|
3415 #else |
3 | 3416 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
|
3417 #endif |
3 | 3418 { |
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
|
3419 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 3420 |
130
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3421 #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
|
3422 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
|
3423 { |
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 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
|
3425 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
|
3426 |
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 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
|
3428 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
|
3429 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
|
3430 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
|
3431 } |
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
|
3432 #else |
3 | 3433 if(tmp && GTK_IS_TEXT(tmp)) |
3434 { | |
3435 int len = gtk_text_get_length(GTK_TEXT(tmp)); | |
3436 gchar *tmpbuf; | |
3437 | |
3438 tmpbuf = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), 0, len); | |
3439 if(tmpbuf) | |
3440 { | |
3441 int z, textlen; | |
3442 | |
3443 textlen = strlen(text); | |
3444 | |
3445 if(flags & DW_MLE_CASESENSITIVE) | |
3446 { | |
3447 for(z=point;z<(len-textlen) && !retval;z++) | |
3448 { | |
3449 if(strncmp(&tmpbuf[z], text, textlen) == 0) | |
3450 retval = z + textlen; | |
3451 } | |
3452 } | |
3453 else | |
3454 { | |
3455 for(z=point;z<(len-textlen) && !retval;z++) | |
3456 { | |
3457 if(strncasecmp(&tmpbuf[z], text, textlen) == 0) | |
3458 retval = z + textlen; | |
3459 } | |
3460 } | |
3461 | |
3462 if(retval) | |
3463 { | |
3464 gtk_text_set_point(GTK_TEXT(tmp), retval - textlen); | |
3465 gtk_editable_select_region(&(GTK_TEXT(tmp)->editable), retval - textlen, retval); | |
3466 } | |
3467 | |
3468 g_free(tmpbuf); | |
3469 } | |
3470 } | |
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
|
3471 #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
|
3472 } |
3 | 3473 DW_MUTEX_UNLOCK; |
3474 return retval; | |
3475 } | |
3476 | |
3477 /* | |
3478 * Stops redrawing of an MLE box. | |
3479 * Parameters: | |
3480 * handle: Handle to the MLE to freeze. | |
3481 */ | |
3482 void dw_mle_freeze(HWND handle) | |
3483 { | |
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
|
3484 #if GTK_MAJOR_VERSION < 2 |
3 | 3485 int _locked_by_me = FALSE; |
3486 | |
3487 DW_MUTEX_LOCK; | |
3488 if(GTK_IS_BOX(handle)) | |
3489 { | |
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
|
3490 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 3491 |
3492 if(tmp && GTK_IS_TEXT(tmp)) | |
3493 { | |
3494 gtk_text_freeze(GTK_TEXT(tmp)); | |
3495 } | |
3496 } | |
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
|
3497 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
|
3498 #endif |
3 | 3499 } |
3500 | |
3501 /* | |
3502 * Resumes redrawing of an MLE box. | |
3503 * Parameters: | |
3504 * handle: Handle to the MLE to thaw. | |
3505 */ | |
3506 void dw_mle_thaw(HWND handle) | |
3507 { | |
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
|
3508 #if GTK_MAJOR_VERSION < 2 |
3 | 3509 int _locked_by_me = FALSE; |
3510 | |
3511 DW_MUTEX_LOCK; | |
3512 if(GTK_IS_BOX(handle)) | |
3513 { | |
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
|
3514 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 3515 |
3516 if(tmp && GTK_IS_TEXT(tmp)) | |
3517 { | |
3518 gtk_text_thaw(GTK_TEXT(tmp)); | |
3519 } | |
3520 } | |
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
|
3521 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
|
3522 #endif |
3 | 3523 } |
3524 | |
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 * Returns the range of the percent bar. |
3 | 3527 * 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
|
3528 * handle: Handle to the percent bar to be queried. |
3 | 3529 */ |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
3530 unsigned int dw_percent_query_range(HWND handle) |
3 | 3531 { |
3532 return 100; | |
3533 } | |
3534 | |
3535 /* | |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
3536 * Sets the percent bar position. |
3 | 3537 * 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
|
3538 * 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
|
3539 * position: Position of the percent bar withing the range. |
3 | 3540 */ |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
3541 void dw_percent_set_pos(HWND handle, unsigned int position) |
3 | 3542 { |
3543 int _locked_by_me = FALSE; | |
3544 | |
3545 DW_MUTEX_LOCK; | |
3546 gtk_progress_bar_update(GTK_PROGRESS_BAR(handle), (gfloat)position/100); | |
3547 DW_MUTEX_UNLOCK; | |
3548 } | |
3549 | |
3550 /* | |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3551 * 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
|
3552 * Parameters: |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3553 * 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
|
3554 */ |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3555 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
|
3556 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3557 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
|
3558 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
|
3559 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3560 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
|
3561 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
|
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 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
|
3564 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
|
3565 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
|
3566 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3567 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
|
3568 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
|
3569 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3570 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
|
3571 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
|
3572 else |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3573 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
|
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 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
|
3576 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
|
3577 } |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3578 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3579 /* |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3580 * 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
|
3581 * Parameters: |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3582 * 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
|
3583 * 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
|
3584 */ |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3585 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
|
3586 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3587 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
|
3588 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
|
3589 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3590 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
|
3591 return; |
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 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
|
3594 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
|
3595 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
|
3596 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3597 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
|
3598 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3599 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
|
3600 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
|
3601 else |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3602 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
|
3603 } |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3604 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
|
3605 } |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3606 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3607 /* |
195
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3608 * 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
|
3609 * Parameters: |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3610 * 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
|
3611 */ |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3612 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
|
3613 { |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3614 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
|
3615 GtkAdjustment *adjustment; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3616 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3617 if(!handle) |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3618 return 0; |
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 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
|
3621 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
|
3622 if(adjustment) |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3623 { |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3624 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
|
3625 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
|
3626 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3627 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
|
3628 val = max - thisval; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3629 else |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3630 val = thisval; |
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 DW_MUTEX_UNLOCK; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3633 return val; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3634 } |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3635 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3636 /* |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3637 * 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
|
3638 * Parameters: |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3639 * 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
|
3640 * 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
|
3641 */ |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3642 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
|
3643 { |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3644 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
|
3645 GtkAdjustment *adjustment; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3646 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3647 if(!handle) |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3648 return; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3649 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3650 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
|
3651 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
|
3652 if(adjustment) |
215
03e68274623d
Two scrollbar fixes for GTK... one from Mark Hessling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
214
diff
changeset
|
3653 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
|
3654 DW_MUTEX_UNLOCK; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3655 } |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3656 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3657 /* |
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
|
3658 * 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
|
3659 * 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
|
3660 * 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
|
3661 * 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
|
3662 * 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
|
3663 */ |
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
3664 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
|
3665 { |
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 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
|
3667 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
|
3668 |
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
|
3669 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
|
3670 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
|
3671 |
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
|
3672 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
|
3673 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
|
3674 if(adjustment) |
205
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
3675 { |
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
3676 adjustment->upper = (gdouble)range; |
216 | 3677 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
|
3678 } |
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
|
3679 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
|
3680 } |
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
|
3681 |
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
|
3682 /* |
3 | 3683 * Sets the spinbutton value. |
3684 * Parameters: | |
3685 * handle: Handle to the spinbutton to be set. | |
3686 * position: Current value of the spinbutton. | |
3687 */ | |
3688 void dw_spinbutton_set_pos(HWND handle, long position) | |
3689 { | |
3690 int _locked_by_me = FALSE; | |
3691 | |
3692 DW_MUTEX_LOCK; | |
3693 gtk_spin_button_set_value(GTK_SPIN_BUTTON(handle), (gfloat)position); | |
3694 DW_MUTEX_UNLOCK; | |
3695 } | |
3696 | |
3697 /* | |
3698 * Sets the spinbutton limits. | |
3699 * Parameters: | |
3700 * handle: Handle to the spinbutton to be set. | |
3701 * position: Current value of the spinbutton. | |
3702 * position: Current value of the spinbutton. | |
3703 */ | |
3704 void dw_spinbutton_set_limits(HWND handle, long upper, long lower) | |
3705 { | |
3706 long curval; | |
3707 GtkAdjustment *adj; | |
3708 int _locked_by_me = FALSE; | |
3709 | |
3710 curval = dw_spinbutton_query(handle); | |
3711 DW_MUTEX_LOCK; | |
3712 adj = (GtkAdjustment *)gtk_adjustment_new((gfloat)curval, (gfloat)lower, (gfloat)upper, 1.0, 5.0, 0.0); | |
3713 DW_MUTEX_UNLOCK; | |
3714 } | |
3715 | |
3716 /* | |
3717 * Sets the entryfield character limit. | |
3718 * Parameters: | |
3719 * handle: Handle to the spinbutton to be set. | |
3720 * limit: Number of characters the entryfield will take. | |
3721 */ | |
3722 void dw_entryfield_set_limit(HWND handle, ULONG limit) | |
3723 { | |
270
d2a80e648d33
Implemented dw_entryfield_set_limit() on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
269
diff
changeset
|
3724 int _locked_by_me = FALSE; |
d2a80e648d33
Implemented dw_entryfield_set_limit() on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
269
diff
changeset
|
3725 |
d2a80e648d33
Implemented dw_entryfield_set_limit() on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
269
diff
changeset
|
3726 DW_MUTEX_LOCK; |
271
38d8908c4438
Corrected incorrect typecast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
270
diff
changeset
|
3727 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
|
3728 DW_MUTEX_UNLOCK; |
3 | 3729 } |
3730 | |
3731 /* | |
3732 * Returns the current value of the spinbutton. | |
3733 * Parameters: | |
3734 * handle: Handle to the spinbutton to be queried. | |
3735 */ | |
3736 long dw_spinbutton_query(HWND handle) | |
3737 { | |
3738 long retval; | |
3739 int _locked_by_me = FALSE; | |
3740 | |
3741 DW_MUTEX_LOCK; | |
3742 retval = (long)gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(handle)); | |
3743 DW_MUTEX_UNLOCK; | |
3744 | |
3745 return retval; | |
3746 } | |
3747 | |
3748 /* | |
3749 * Returns the state of the checkbox. | |
3750 * Parameters: | |
3751 * handle: Handle to the checkbox to be queried. | |
3752 */ | |
3753 int dw_checkbox_query(HWND handle) | |
3754 { | |
3755 int retval; | |
3756 int _locked_by_me = FALSE; | |
3757 | |
3758 DW_MUTEX_LOCK; | |
3759 retval = GTK_TOGGLE_BUTTON(handle)->active; | |
3760 DW_MUTEX_UNLOCK; | |
3761 | |
3762 return retval; | |
3763 } | |
3764 | |
3765 /* | |
3766 * Sets the state of the checkbox. | |
3767 * Parameters: | |
3768 * handle: Handle to the checkbox to be queried. | |
3769 * value: TRUE for checked, FALSE for unchecked. | |
3770 */ | |
3771 void dw_checkbox_set(HWND handle, int value) | |
3772 { | |
3773 int _locked_by_me = FALSE; | |
3774 | |
3775 DW_MUTEX_LOCK; | |
3776 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(handle), value); | |
3777 DW_MUTEX_UNLOCK; | |
3778 } | |
3779 | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3780 /* |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3781 * 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
|
3782 * Parameters: |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3783 * 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
|
3784 * 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
|
3785 * title: The text title of the entry. |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3786 * icon: Handle to coresponding icon. |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3787 * parent: Parent handle or 0 if root. |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3788 * itemdata: Item specific data. |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3789 */ |
329
9b1953ed0bff
Oops missed one parameter change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
328
diff
changeset
|
3790 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
|
3791 { |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3792 #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
|
3793 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
|
3794 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
|
3795 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
|
3796 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
|
3797 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
|
3798 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
|
3799 |
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(!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 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
|
3802 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3803 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
|
3804 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
|
3805 && 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
|
3806 (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
|
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 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
|
3809 |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3810 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
|
3811 |
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
|
3812 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
|
3813 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
|
3814 if(pixbuf) |
63d68387d924
Don't unref a non-existant pixmap. (GTK 2.x)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
255
diff
changeset
|
3815 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
|
3816 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
|
3817 } |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3818 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
|
3819 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3820 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
|
3821 #else |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3822 GtkWidget *newitem, *tree, *subtree, *label, *hbox, *pixmap; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3823 GdkPixmap *gdkpix; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3824 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
|
3825 int position = -1; |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3826 int _locked_by_me = FALSE; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3827 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3828 if(!handle) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3829 return NULL; |
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_LOCK; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3832 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
|
3833 if(!tree || !GTK_IS_TREE(tree)) |
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 DW_MUTEX_UNLOCK; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3836 return NULL; |
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 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3839 if(item && GTK_IS_TREE_ITEM(item)) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3840 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
|
3841 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3842 position++; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3843 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3844 newitem = gtk_tree_item_new(); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3845 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
|
3846 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
|
3847 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
|
3848 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
|
3849 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
|
3850 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
|
3851 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
|
3852 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
|
3853 if(gdkpix) |
a167001c56df
Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
249
diff
changeset
|
3854 { |
a167001c56df
Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
249
diff
changeset
|
3855 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
|
3856 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
|
3857 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
|
3858 } |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3859 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
|
3860 gtk_widget_show(label); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3861 gtk_widget_show(hbox); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3862 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3863 if(parent) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3864 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3865 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
|
3866 if(!subtree) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3867 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
3868 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
|
3869 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
|
3870 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
|
3871 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3872 subtree = gtk_tree_new(); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3873 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3874 if(thisfunc && work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3875 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3876 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
|
3877 (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
|
3878 } |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3879 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
3880 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
|
3881 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
|
3882 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
|
3883 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3884 if(thisfunc && work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3885 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3886 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
|
3887 (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
|
3888 } |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3889 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3890 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
|
3891 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
|
3892 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
|
3893 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
|
3894 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
|
3895 gtk_widget_show(subtree); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3896 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
|
3897 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
|
3898 } |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
3899 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
|
3900 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
|
3901 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3902 else |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3903 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
3904 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
|
3905 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
|
3906 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3907 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
|
3908 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
|
3909 gtk_widget_show(newitem); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3910 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
|
3911 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
|
3912 #endif |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3913 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3914 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3915 /* |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3916 * 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
|
3917 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3918 * 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
|
3919 * 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
|
3920 * 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
|
3921 * 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
|
3922 * 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
|
3923 */ |
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
|
3924 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
|
3925 { |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3926 #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
|
3927 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
|
3928 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
|
3929 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
|
3930 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
|
3931 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
|
3932 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
|
3933 |
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(!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 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
|
3936 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3937 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
|
3938 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
|
3939 && 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
|
3940 (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
|
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 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
|
3943 |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3944 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
|
3945 |
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
|
3946 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
|
3947 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
|
3948 if(pixbuf) |
63d68387d924
Don't unref a non-existant pixmap. (GTK 2.x)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
255
diff
changeset
|
3949 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
|
3950 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
|
3951 } |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3952 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
|
3953 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3954 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
|
3955 #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
|
3956 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
|
3957 GdkPixmap *gdkpix; |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3958 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
|
3959 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
|
3960 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3961 if(!handle) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3962 return NULL; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3963 |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3964 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
|
3965 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
|
3966 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
|
3967 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3968 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
|
3969 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
|
3970 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3971 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
|
3972 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
|
3973 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
|
3974 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
|
3975 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
|
3976 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
|
3977 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
|
3978 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
|
3979 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
|
3980 if(gdkpix) |
a167001c56df
Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
249
diff
changeset
|
3981 { |
a167001c56df
Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
249
diff
changeset
|
3982 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
|
3983 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
|
3984 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
|
3985 } |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3986 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
|
3987 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
|
3988 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
|
3989 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3990 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
|
3991 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3992 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
|
3993 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
|
3994 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
3995 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
|
3996 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
|
3997 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
|
3998 |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3999 subtree = gtk_tree_new(); |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4000 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
4001 if(thisfunc && work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
4002 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
4003 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
|
4004 (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
|
4005 } |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4006 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4007 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
|
4008 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
|
4009 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
|
4010 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
4011 if(thisfunc && work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
4012 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
4013 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
|
4014 (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
|
4015 } |
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
|
4016 |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4017 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
|
4018 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
|
4019 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
|
4020 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
|
4021 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
|
4022 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
|
4023 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
|
4024 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
|
4025 } |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4026 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
|
4027 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
|
4028 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4029 else |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4030 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4031 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
|
4032 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
|
4033 } |
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
|
4034 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
|
4035 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
|
4036 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
|
4037 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
|
4038 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
|
4039 #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
|
4040 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4041 |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4042 /* |
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
|
4043 * 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
|
4044 * 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
|
4045 * 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
|
4046 * 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
|
4047 * 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
|
4048 * 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
|
4049 */ |
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
|
4050 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
|
4051 { |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4052 #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
|
4053 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
|
4054 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
|
4055 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
|
4056 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
|
4057 |
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(!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 return; |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4060 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4061 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
|
4062 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
|
4063 && 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
|
4064 (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
|
4065 { |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4066 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
|
4067 |
139
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4068 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
|
4069 if(pixbuf) |
63d68387d924
Don't unref a non-existant pixmap. (GTK 2.x)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
255
diff
changeset
|
4070 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
|
4071 } |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4072 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
|
4073 #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
|
4074 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
|
4075 GdkPixmap *gdkpix; |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4076 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
|
4077 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
|
4078 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
|
4079 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4080 if(!handle || !item) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4081 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4082 |
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
|
4083 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
|
4084 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
|
4085 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
|
4086 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
|
4087 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
|
4088 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
|
4089 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
|
4090 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
|
4091 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
|
4092 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
|
4093 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
|
4094 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
|
4095 if(gdkpix) |
a167001c56df
Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
249
diff
changeset
|
4096 { |
a167001c56df
Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
249
diff
changeset
|
4097 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
|
4098 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
|
4099 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
|
4100 } |
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
|
4101 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
|
4102 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
|
4103 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
|
4104 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
|
4105 #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
|
4106 } |
c4e1139d9872
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 |
c4e1139d9872
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 /* |
c4e1139d9872
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 * 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
|
4110 * 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
|
4111 * 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
|
4112 * 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
|
4113 * 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
|
4114 */ |
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
|
4115 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
|
4116 { |
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
|
4117 #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
|
4118 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
|
4119 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
|
4120 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
|
4121 |
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(!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
|
4123 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
|
4124 |
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 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
|
4126 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
|
4127 && 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
|
4128 (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
|
4129 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
|
4130 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
|
4131 #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
|
4132 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
|
4133 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4134 if(!handle || !item) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4135 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4136 |
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 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
|
4138 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
|
4139 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
|
4140 #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
|
4141 } |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
4142 |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
4143 /* |
317
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4144 * 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
|
4145 * Parameters: |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4146 * 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
|
4147 * 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
|
4148 */ |
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
|
4149 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
|
4150 { |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4151 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
|
4152 #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
|
4153 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
|
4154 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
|
4155 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
|
4156 |
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(!handle || !item) |
319
aed5d742896d
Fixed errant returns on failure.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
317
diff
changeset
|
4158 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
|
4159 |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4160 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
|
4161 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
|
4162 && 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
|
4163 (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
|
4164 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
|
4165 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
|
4166 #else |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4167 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
|
4168 |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4169 if(!handle || !item) |
319
aed5d742896d
Fixed errant returns on failure.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
317
diff
changeset
|
4170 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
|
4171 |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4172 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
|
4173 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
|
4174 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
|
4175 #endif |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4176 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
|
4177 } |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4178 |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4179 /* |
54
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
4180 * 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
|
4181 * 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
|
4182 * 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
|
4183 * 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
|
4184 */ |
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
|
4185 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
|
4186 { |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4187 #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
|
4188 GtkWidget *tree; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4189 GtkTreeStore *store; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4190 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
|
4191 |
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
|
4192 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
|
4193 return; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4194 |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4195 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
|
4196 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
|
4197 && 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
|
4198 (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
|
4199 { |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4200 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
|
4201 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
|
4202 |
139
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4203 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
|
4204 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
|
4205 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
|
4206 } |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4207 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
|
4208 #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
|
4209 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
|
4210 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
|
4211 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4212 if(!handle || !item) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4213 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4214 |
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
|
4215 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
|
4216 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
|
4217 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
|
4218 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
|
4219 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
|
4220 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
|
4221 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
|
4222 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
|
4223 #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
|
4224 } |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
4225 |
143
1d57c27e4adc
Moved _dw_recursive_free into GTK 2.0 #ifdefs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
142
diff
changeset
|
4226 #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
|
4227 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
|
4228 { |
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 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
|
4230 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
|
4231 |
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 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
|
4233 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
|
4234 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
|
4235 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
|
4236 |
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 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
|
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 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
|
4240 _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
|
4241 } 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
|
4242 } |
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
|
4243 } |
143
1d57c27e4adc
Moved _dw_recursive_free into GTK 2.0 #ifdefs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
142
diff
changeset
|
4244 #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
|
4245 |
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
|
4246 /* |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4247 * Removes all nodes from a tree. |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4248 * Parameters: |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4249 * 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
|
4250 */ |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4251 void dw_tree_clear(HWND handle) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4252 { |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4253 #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
|
4254 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
|
4255 GtkTreeStore *store; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4256 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
|
4257 |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4258 if(!handle) |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4259 return; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4260 |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4261 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
|
4262 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
|
4263 && 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
|
4264 (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
|
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 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
|
4267 |
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 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
|
4269 { |
36dc19aa7773
Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
140
diff
changeset
|
4270 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
|
4271 _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
|
4272 } 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
|
4273 } |
139
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4274 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
|
4275 } |
139
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4276 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
|
4277 #else |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4278 GtkWidget *tree; |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4279 int _locked_by_me = FALSE; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4280 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4281 if(!handle) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4282 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4283 |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4284 DW_MUTEX_LOCK; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4285 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
|
4286 if(!tree || !GTK_IS_TREE(tree)) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4287 { |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4288 DW_MUTEX_UNLOCK; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4289 return; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4290 } |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4291 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
|
4292 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
|
4293 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
|
4294 #endif |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4295 } |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4296 |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4297 /* |
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
|
4298 * 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
|
4299 * 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
|
4300 * 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
|
4301 * 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
|
4302 */ |
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
|
4303 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
|
4304 { |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4305 #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
|
4306 GtkWidget *tree; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4307 GtkTreeStore *store; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4308 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
|
4309 |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4310 if(!handle) |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4311 return; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4312 |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4313 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
|
4314 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
|
4315 && 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
|
4316 (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
|
4317 { |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4318 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
|
4319 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
|
4320 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
|
4321 } |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4322 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
|
4323 #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
|
4324 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
|
4325 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4326 if(!handle || !item) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4327 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4328 |
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
|
4329 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
|
4330 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
|
4331 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
|
4332 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
|
4333 #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
|
4334 } |
c4e1139d9872
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 |
c4e1139d9872
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 /* |
c4e1139d9872
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 * 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
|
4338 * 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
|
4339 * 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
|
4340 * 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
|
4341 */ |
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
|
4342 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
|
4343 { |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4344 #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
|
4345 GtkWidget *tree; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4346 GtkTreeStore *store; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4347 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
|
4348 |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4349 if(!handle) |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4350 return; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4351 |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4352 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
|
4353 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
|
4354 && 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
|
4355 (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
|
4356 { |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4357 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
|
4358 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
|
4359 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
|
4360 } |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4361 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
|
4362 #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
|
4363 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
|
4364 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4365 if(!handle || !item) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4366 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4367 |
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
|
4368 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
|
4369 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
|
4370 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
|
4371 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
|
4372 #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
|
4373 } |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
4374 |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
4375 /* |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4376 * Removes a node from a tree. |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4377 * Parameters: |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4378 * 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
|
4379 * item: Handle to node to be deleted. |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4380 */ |
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
|
4381 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
|
4382 { |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4383 #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
|
4384 GtkWidget *tree; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4385 GtkTreeStore *store; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4386 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
|
4387 |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4388 if(!handle) |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4389 return; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4390 |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4391 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
|
4392 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
|
4393 && 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
|
4394 (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
|
4395 { |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4396 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
|
4397 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
|
4398 } |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4399 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
|
4400 #else |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4401 GtkWidget *tree, *lastselect, *parenttree; |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4402 int _locked_by_me = FALSE; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4403 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4404 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
|
4405 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4406 |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4407 DW_MUTEX_LOCK; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4408 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
|
4409 if(!tree || !GTK_IS_TREE(tree)) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4410 { |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4411 DW_MUTEX_UNLOCK; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4412 return; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4413 } |
54
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
4414 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4415 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
|
4416 |
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4417 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
|
4418 |
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
|
4419 if(lastselect == item) |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4420 { |
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
|
4421 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
|
4422 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
|
4423 } |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4424 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4425 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
|
4426 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
|
4427 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
|
4428 #endif |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4429 } |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4430 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4431 static int _dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator, int extra) |
3 | 4432 { |
4433 GtkWidget *clist; | |
4434 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
|
4435 int z, multi; |
3 | 4436 int _locked_by_me = FALSE; |
355
3a71623fc219
Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
354
diff
changeset
|
4437 GtkJustification justification; |
3 | 4438 |
4439 DW_MUTEX_LOCK; | |
4440 clist = gtk_clist_new_with_titles(count, (gchar **)titles); | |
4441 if(!clist) | |
4442 { | |
4443 DW_MUTEX_UNLOCK; | |
4444 return FALSE; | |
4445 } | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4446 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
|
4447 gtk_object_set_data(GTK_OBJECT(handle), "_dw_multi", (gpointer)multi); |
3 | 4448 |
4449 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
|
4450 if(multi) |
2216e65ad2ae
Removed slider flags and container selection flags from the header file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
346
diff
changeset
|
4451 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
|
4452 else |
2216e65ad2ae
Removed slider flags and container selection flags from the header file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
346
diff
changeset
|
4453 gtk_clist_set_selection_mode(GTK_CLIST(clist), GTK_SELECTION_SINGLE); |
3 | 4454 gtk_container_add(GTK_CONTAINER(handle), clist); |
4455 gtk_object_set_user_data(GTK_OBJECT(handle), (gpointer)clist); | |
4456 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
|
4457 gtk_object_set_data(GTK_OBJECT(clist), "_dw_colcount", (gpointer)count); |
3 | 4458 |
4459 if(extra) | |
4460 gtk_clist_set_column_width(GTK_CLIST(clist), 1, 120); | |
4461 | |
4462 for(z=0;z<count;z++) | |
4463 { | |
4464 if(!extra || z > 1) | |
4465 gtk_clist_set_column_width(GTK_CLIST(clist), z, 50); | |
4466 sprintf(numbuf, "%d", z); | |
4467 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
|
4468 if(flags[z]&DW_CFA_RIGHT) |
3a71623fc219
Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
354
diff
changeset
|
4469 justification = GTK_JUSTIFY_RIGHT; |
3a71623fc219
Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
354
diff
changeset
|
4470 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
|
4471 justification = GTK_JUSTIFY_CENTER; |
3a71623fc219
Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
354
diff
changeset
|
4472 else |
3a71623fc219
Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
354
diff
changeset
|
4473 justification = GTK_JUSTIFY_LEFT; |
3a71623fc219
Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
354
diff
changeset
|
4474 gtk_clist_set_column_justification(GTK_CLIST(clist),z,justification); |
3 | 4475 } |
4476 | |
4477 DW_MUTEX_UNLOCK; | |
4478 return TRUE; | |
4479 } | |
4480 | |
4481 /* | |
4482 * Sets up the container columns. | |
4483 * Parameters: | |
4484 * handle: Handle to the container to be configured. | |
4485 * flags: An array of unsigned longs with column flags. | |
4486 * titles: An array of strings with column text titles. | |
4487 * count: The number of columns (this should match the arrays). | |
4488 * separator: The column number that contains the main separator. | |
4489 * (this item may only be used in OS/2) | |
4490 */ | |
4491 int dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator) | |
4492 { | |
4493 return _dw_container_setup(handle, flags, titles, count, separator, 0); | |
4494 } | |
4495 | |
4496 /* | |
4497 * Sets up the filesystem columns, note: filesystem always has an icon/filename field. | |
4498 * Parameters: | |
4499 * handle: Handle to the container to be configured. | |
4500 * flags: An array of unsigned longs with column flags. | |
4501 * titles: An array of strings with column text titles. | |
4502 * count: The number of columns (this should match the arrays). | |
4503 */ | |
4504 int dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count) | |
4505 { | |
4506 char **newtitles = malloc(sizeof(char *) * (count + 2)); | |
4507 unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 2)); | |
4508 | |
4509 newtitles[0] = "Icon"; | |
4510 newtitles[1] = "Filename"; | |
4511 | |
4512 newflags[0] = DW_CFA_BITMAPORICON | DW_CFA_CENTER | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR; | |
4513 newflags[1] = DW_CFA_STRING | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR; | |
4514 | |
4515 memcpy(&newtitles[2], titles, sizeof(char *) * count); | |
4516 memcpy(&newflags[2], flags, sizeof(unsigned long) * count); | |
4517 | |
4518 _dw_container_setup(handle, newflags, newtitles, count + 2, 2, 1); | |
4519 | |
4520 free(newtitles); | |
4521 free(newflags); | |
4522 return TRUE; | |
4523 } | |
4524 | |
4525 /* | |
4526 * Obtains an icon from a module (or header in GTK). | |
4527 * Parameters: | |
4528 * module: Handle to module (DLL) in OS/2 and Windows. | |
4529 * id: A unsigned long id int the resources on OS/2 and | |
4530 * Windows, on GTK this is converted to a pointer | |
4531 * to an embedded XPM. | |
4532 */ | |
4533 unsigned long dw_icon_load(unsigned long module, unsigned long id) | |
4534 { | |
4535 return id; | |
4536 } | |
4537 | |
4538 /* | |
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
|
4539 * 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
|
4540 * 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
|
4541 * 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
|
4542 * 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
|
4543 * (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
|
4544 */ |
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
|
4545 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
|
4546 { |
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
|
4547 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
|
4548 #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
|
4549 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
|
4550 #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
|
4551 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
|
4552 #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
|
4553 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
|
4554 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
|
4555 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4556 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
|
4557 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
|
4558 |
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 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
|
4560 |
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 /* 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
|
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 { |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4564 /* 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
|
4565 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
|
4566 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
|
4567 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
|
4568 } |
258
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 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
|
4571 /* 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
|
4572 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
|
4573 { |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4574 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
|
4575 { |
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
|
4576 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
|
4577 break; |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4578 } |
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 |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4581 /* 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
|
4582 * array. |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4583 */ |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4584 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
|
4585 { |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4586 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
|
4587 |
265
84471d53ab58
Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
264
diff
changeset
|
4588 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
|
4589 _PixmapCount++; |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4590 |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4591 _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
|
4592 |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4593 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
|
4594 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
|
4595 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
|
4596 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
|
4597 _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
|
4598 _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
|
4599 } |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4600 |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4601 #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
|
4602 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
|
4603 |
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
|
4604 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
|
4605 { |
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
|
4606 _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
|
4607 _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
|
4608 _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
|
4609 |
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
|
4610 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
|
4611 } |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4612 #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
|
4613 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
|
4614 |
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
|
4615 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
|
4616 { |
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].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
|
4618 _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
|
4619 |
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 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
|
4621 _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
|
4622 _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
|
4623 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
|
4624 } |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4625 #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
|
4626 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
|
4627 _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
|
4628 #endif |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4629 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
|
4630 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
|
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 _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
|
4633 _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
|
4634 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
|
4635 } |
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
|
4636 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
|
4637 } |
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
|
4638 |
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
|
4639 /* |
3 | 4640 * Frees a loaded resource in OS/2 and Windows. |
4641 * Parameters: | |
4642 * handle: Handle to icon returned by dw_icon_load(). | |
4643 */ | |
4644 void dw_icon_free(unsigned long handle) | |
4645 { | |
258
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 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
|
4647 * 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
|
4648 * 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
|
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(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
|
4651 { |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4652 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
|
4653 |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4654 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
|
4655 { |
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
|
4656 #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
|
4657 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
|
4658 { |
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
|
4659 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
|
4660 _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
|
4661 } |
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
|
4662 #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
|
4663 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
|
4664 { |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4665 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
|
4666 _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
|
4667 } |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4668 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
|
4669 { |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4670 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
|
4671 _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
|
4672 } |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4673 _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
|
4674 } |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4675 } |
3 | 4676 } |
4677 | |
72
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
4678 /* 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
|
4679 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
|
4680 { |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
4681 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
|
4682 } |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
4683 |
3 | 4684 /* |
4685 * Allocates memory used to populate a container. | |
4686 * Parameters: | |
4687 * handle: Handle to the container window (widget). | |
4688 * rowcount: The number of items to be populated. | |
4689 */ | |
4690 void *dw_container_alloc(HWND handle, int rowcount) | |
4691 { | |
4692 int z, count = 0; | |
4693 GtkWidget *clist; | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
4694 GdkColor *fore, *back; |
3 | 4695 char **blah; |
4696 int _locked_by_me = FALSE; | |
4697 | |
4698 DW_MUTEX_LOCK; | |
4699 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
4700 if(!clist) | |
4701 { | |
4702 DW_MUTEX_UNLOCK; | |
4703 return NULL; | |
4704 } | |
4705 | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4706 count = (int)gtk_object_get_data(GTK_OBJECT(clist), "_dw_colcount"); |
3 | 4707 |
4708 if(!count) | |
4709 { | |
4710 DW_MUTEX_UNLOCK; | |
4711 return NULL; | |
4712 } | |
4713 | |
4714 blah = malloc(sizeof(char *) * count); | |
4715 memset(blah, 0, sizeof(char *) * count); | |
4716 | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4717 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
|
4718 back = (GdkColor *)gtk_object_get_data(GTK_OBJECT(clist), "_dw_backgdk"); |
3 | 4719 gtk_clist_freeze(GTK_CLIST(clist)); |
4720 for(z=0;z<rowcount;z++) | |
4721 { | |
4722 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
|
4723 if(fore) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
4724 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
|
4725 if(back) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
4726 gtk_clist_set_background(GTK_CLIST(clist), z, back); |
3 | 4727 } |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4728 gtk_object_set_data(GTK_OBJECT(clist), "_dw_rowcount", (gpointer)rowcount); |
3 | 4729 free(blah); |
4730 DW_MUTEX_UNLOCK; | |
4731 return (void *)handle; | |
4732 } | |
4733 | |
4734 /* | |
4735 * Sets an item in specified row and column to the given data. | |
4736 * Parameters: | |
4737 * handle: Handle to the container window (widget). | |
4738 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
4739 * column: Zero based column of data being set. | |
4740 * row: Zero based row of data being set. | |
4741 * data: Pointer to the data to be added. | |
4742 */ | |
4743 void dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data) | |
4744 { | |
4745 char numbuf[10], textbuffer[100]; | |
4746 int flag = 0; | |
4747 GtkWidget *clist; | |
4748 int _locked_by_me = FALSE; | |
4749 | |
4750 DW_MUTEX_LOCK; | |
4751 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
4752 if(!clist) | |
4753 { | |
4754 DW_MUTEX_UNLOCK; | |
4755 return; | |
4756 } | |
4757 | |
4758 sprintf(numbuf, "%d", column); | |
4759 flag = (int)gtk_object_get_data(GTK_OBJECT(clist), numbuf); | |
4760 | |
4761 if(flag & DW_CFA_BITMAPORICON) | |
4762 { | |
4763 long hicon = *((long *)data); | |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4764 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
|
4765 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
|
4766 |
3 | 4767 if(pixmap) |
4768 gtk_clist_set_pixmap(GTK_CLIST(clist), row, column, pixmap, bitmap); | |
4769 } | |
4770 else if(flag & DW_CFA_STRING) | |
4771 { | |
4772 char *tmp = *((char **)data); | |
4773 gtk_clist_set_text(GTK_CLIST(clist), row, column, tmp); | |
4774 } | |
4775 else if(flag & DW_CFA_ULONG) | |
4776 { | |
4777 ULONG tmp = *((ULONG *)data); | |
4778 | |
4779 sprintf(textbuffer, "%lu", tmp); | |
4780 | |
4781 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer); | |
4782 } | |
4783 else if(flag & DW_CFA_DATE) | |
4784 { | |
165
d03716228b7f
Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
164
diff
changeset
|
4785 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
|
4786 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
|
4787 |
d03716228b7f
Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
164
diff
changeset
|
4788 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
|
4789 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
|
4790 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
|
4791 |
d03716228b7f
Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
164
diff
changeset
|
4792 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
|
4793 |
3 | 4794 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer); |
4795 } | |
4796 else if(flag & DW_CFA_TIME) | |
4797 { | |
165
d03716228b7f
Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
164
diff
changeset
|
4798 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
|
4799 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
|
4800 |
d03716228b7f
Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
164
diff
changeset
|
4801 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
|
4802 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
|
4803 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
|
4804 |
d03716228b7f
Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
164
diff
changeset
|
4805 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
|
4806 |
3 | 4807 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer); |
4808 } | |
4809 DW_MUTEX_UNLOCK; | |
4810 } | |
4811 | |
4812 /* | |
167
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
4813 * 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
|
4814 * Parameters: |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
4815 * 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
|
4816 * 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
|
4817 * 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
|
4818 * 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
|
4819 */ |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
4820 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
|
4821 { |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
4822 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
|
4823 } |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
4824 |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
4825 /* |
3 | 4826 * Sets an item in specified row and column to the given data. |
4827 * Parameters: | |
4828 * handle: Handle to the container window (widget). | |
4829 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
4830 * column: Zero based column of data being set. | |
4831 * row: Zero based row of data being set. | |
4832 * data: Pointer to the data to be added. | |
4833 */ | |
4834 void dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, unsigned long icon) | |
4835 { | |
4836 dw_container_set_item(handle, pointer, 0, row, (void *)&icon); | |
4837 dw_container_set_item(handle, pointer, 1, row, (void *)&filename); | |
4838 } | |
4839 | |
4840 /* | |
4841 * Sets an item in specified row and column to the given data. | |
4842 * Parameters: | |
4843 * handle: Handle to the container window (widget). | |
4844 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
4845 * column: Zero based column of data being set. | |
4846 * row: Zero based row of data being set. | |
4847 * data: Pointer to the data to be added. | |
4848 */ | |
4849 void dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data) | |
4850 { | |
4851 dw_container_set_item(handle, pointer, column + 2, row, data); | |
4852 } | |
4853 | |
4854 /* | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4855 * 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
|
4856 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4857 * 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
|
4858 * 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
|
4859 * 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
|
4860 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4861 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
|
4862 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4863 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
|
4864 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
|
4865 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4866 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
|
4867 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
|
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 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
|
4870 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
|
4871 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
|
4872 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4873 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4874 /* |
3 | 4875 * Sets the title of a row in the container. |
4876 * Parameters: | |
4877 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
4878 * row: Zero based row of data being set. | |
4879 * title: String title of the item. | |
4880 */ | |
4881 void dw_container_set_row_title(void *pointer, int row, char *title) | |
4882 { | |
4883 GtkWidget *clist; | |
4884 int _locked_by_me = FALSE; | |
4885 | |
4886 DW_MUTEX_LOCK; | |
4887 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(pointer)); | |
4888 | |
4889 if(clist) | |
4890 gtk_clist_set_row_data(GTK_CLIST(clist), row, (gpointer)title); | |
4891 DW_MUTEX_UNLOCK; | |
4892 } | |
4893 | |
4894 /* | |
4895 * Sets the title of a row in the container. | |
4896 * Parameters: | |
4897 * handle: Handle to the container window (widget). | |
4898 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
4899 * rowcount: The number of rows to be inserted. | |
4900 */ | |
4901 void dw_container_insert(HWND handle, void *pointer, int rowcount) | |
4902 { | |
4903 GtkWidget *clist; | |
4904 int _locked_by_me = FALSE; | |
4905 | |
4906 DW_MUTEX_LOCK; | |
4907 clist = gtk_object_get_user_data(GTK_OBJECT(handle)); | |
4908 | |
4909 if(clist && GTK_IS_CLIST(clist)) | |
4910 gtk_clist_thaw(GTK_CLIST(clist)); | |
4911 DW_MUTEX_UNLOCK; | |
4912 } | |
4913 | |
4914 /* | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4915 * 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
|
4916 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4917 * 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
|
4918 * 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
|
4919 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4920 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
|
4921 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4922 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
|
4923 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
|
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 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
|
4926 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
|
4927 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
|
4928 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4929 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
|
4930 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4931 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
|
4932 |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
4933 _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
|
4934 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4935 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
|
4936 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
|
4937 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4938 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
|
4939 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
|
4940 else |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4941 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
|
4942 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4943 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
|
4944 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4945 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
|
4946 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4947 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4948 /* |
3 | 4949 * Removes all rows from a container. |
4950 * Parameters: | |
4951 * 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
|
4952 * redraw: TRUE to cause the container to redraw immediately. |
3 | 4953 */ |
52
0804483f6320
Added a redraw parameter to dw_container_clear().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
51
diff
changeset
|
4954 void dw_container_clear(HWND handle, int redraw) |
3 | 4955 { |
4956 GtkWidget *clist; | |
4957 int _locked_by_me = FALSE; | |
4958 | |
4959 DW_MUTEX_LOCK; | |
4960 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
4961 if(clist && GTK_IS_CLIST(clist)) | |
4962 { | |
72
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
4963 _dw_unselect(clist); |
3 | 4964 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
|
4965 gtk_object_set_data(GTK_OBJECT(clist), "_dw_rowcount", (gpointer)0); |
3 | 4966 } |
4967 DW_MUTEX_UNLOCK; | |
4968 } | |
4969 | |
4970 /* | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4971 * 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
|
4972 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4973 * 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
|
4974 * 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
|
4975 * 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
|
4976 * 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
|
4977 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4978 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
|
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 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
|
4981 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
|
4982 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
|
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 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
|
4985 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
|
4986 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
|
4987 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4988 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
|
4989 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
|
4990 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4991 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
|
4992 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4993 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
|
4994 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
|
4995 break; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4996 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
|
4997 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
|
4998 break; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4999 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5000 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
|
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 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5003 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
|
5004 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5005 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
5006 /* |
3 | 5007 * Starts a new query of a container. |
5008 * Parameters: | |
5009 * handle: Handle to the window (widget) to be queried. | |
5010 * flags: If this parameter is DW_CRA_SELECTED it will only | |
5011 * return items that are currently selected. Otherwise | |
5012 * it will return all records in the container. | |
5013 */ | |
5014 char *dw_container_query_start(HWND handle, unsigned long flags) | |
5015 { | |
5016 GtkWidget *clist; | |
5017 GList *list; | |
5018 char *retval = NULL; | |
5019 int _locked_by_me = FALSE; | |
5020 | |
5021 DW_MUTEX_LOCK; | |
5022 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
5023 | |
5024 if(!clist) | |
5025 { | |
5026 DW_MUTEX_UNLOCK; | |
5027 return NULL; | |
5028 } | |
5029 | |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5030 /* 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
|
5031 if(flags & DW_CRA_SELECTED) |
3 | 5032 { |
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
|
5033 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
|
5034 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5035 if(list) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5036 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5037 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
|
5038 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
|
5039 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5040 } |
364
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
5041 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
|
5042 { |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
5043 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
|
5044 } |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5045 else |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5046 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5047 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
|
5048 gtk_object_set_data(GTK_OBJECT(clist), "_dw_querypos", (gpointer)1); |
3 | 5049 } |
5050 DW_MUTEX_UNLOCK; | |
5051 return retval; | |
5052 } | |
5053 | |
5054 /* | |
5055 * Continues an existing query of a container. | |
5056 * Parameters: | |
5057 * handle: Handle to the window (widget) to be queried. | |
5058 * flags: If this parameter is DW_CRA_SELECTED it will only | |
5059 * return items that are currently selected. Otherwise | |
5060 * it will return all records in the container. | |
5061 */ | |
5062 char *dw_container_query_next(HWND handle, unsigned long flags) | |
5063 { | |
5064 GtkWidget *clist; | |
5065 GList *list; | |
5066 char *retval = NULL; | |
5067 int _locked_by_me = FALSE; | |
5068 | |
5069 DW_MUTEX_LOCK; | |
5070 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
5071 | |
5072 if(!clist) | |
5073 { | |
5074 DW_MUTEX_UNLOCK; | |
5075 return NULL; | |
5076 } | |
5077 | |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5078 /* 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
|
5079 if(flags & DW_CRA_SELECTED) |
3 | 5080 { |
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
|
5081 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
|
5082 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5083 if(list) |
3 | 5084 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5085 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
|
5086 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
|
5087 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5088 while(list && counter < pos) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5089 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5090 list = list->next; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5091 counter++; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5092 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5093 |
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
|
5094 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
|
5095 retval = (char *)gtk_clist_get_row_data(GTK_CLIST(clist), GPOINTER_TO_UINT(list->data)); |
3 | 5096 } |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5097 } |
364
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
5098 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
|
5099 { |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
5100 /* 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
|
5101 * 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
|
5102 */ |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
5103 retval = NULL; |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
5104 } |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5105 else |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5106 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5107 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
|
5108 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5109 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
|
5110 gtk_object_set_data(GTK_OBJECT(clist), "_dw_querypos", (gpointer)pos+1); |
3 | 5111 } |
5112 DW_MUTEX_UNLOCK; | |
5113 return retval; | |
5114 } | |
5115 | |
5116 /* | |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5117 * 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
|
5118 * Parameters: |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5119 * 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
|
5120 * 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
|
5121 */ |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5122 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
|
5123 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5124 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
|
5125 GtkWidget *clist; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5126 int rowcount, z; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5127 char *rowdata; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5128 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5129 DW_MUTEX_LOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5130 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
|
5131 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5132 if(!clist) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5133 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5134 DW_MUTEX_UNLOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5135 return; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5136 } |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5137 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
|
5138 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5139 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
|
5140 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5141 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
|
5142 if(rowdata == text) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5143 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5144 gfloat pos; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5145 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
|
5146 |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
5147 _dw_unselect(clist); |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
5148 |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5149 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
|
5150 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5151 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
|
5152 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
|
5153 DW_MUTEX_UNLOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5154 return; |
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 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5158 DW_MUTEX_UNLOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5159 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5160 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5161 /* |
167
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5162 * 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
|
5163 * Parameters: |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5164 * 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
|
5165 * 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
|
5166 */ |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5167 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
|
5168 { |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5169 int _locked_by_me = FALSE; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5170 GtkWidget *clist; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5171 int rowcount, z; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5172 char *rowdata; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5173 |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5174 DW_MUTEX_LOCK; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5175 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
|
5176 |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5177 if(!clist) |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5178 { |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5179 DW_MUTEX_UNLOCK; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5180 return; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5181 } |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5182 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
|
5183 |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5184 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
|
5185 { |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5186 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
|
5187 if(rowdata == text) |
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 _dw_unselect(clist); |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5190 |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5191 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
|
5192 |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5193 rowcount--; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5194 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5195 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
|
5196 DW_MUTEX_UNLOCK; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5197 return; |
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 |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5201 DW_MUTEX_UNLOCK; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5202 } |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5203 |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5204 /* |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5205 * 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
|
5206 * Parameters: |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5207 * 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
|
5208 */ |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5209 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
|
5210 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5211 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
|
5212 GtkWidget *clist; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5213 int colcount, z; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5214 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5215 DW_MUTEX_LOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5216 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
|
5217 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5218 if(!clist) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5219 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5220 DW_MUTEX_UNLOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5221 return; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5222 } |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5223 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
|
5224 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
|
5225 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5226 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
|
5227 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
|
5228 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5229 DW_MUTEX_UNLOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5230 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5231 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5232 /* |
3 | 5233 * Creates a rendering context widget (window) to be packed. |
5234 * Parameters: | |
5235 * id: An id to be used with dw_window_from_id. | |
5236 * Returns: | |
5237 * A handle to the widget or NULL on failure. | |
5238 */ | |
5239 HWND dw_render_new(unsigned long id) | |
5240 { | |
5241 int _locked_by_me = FALSE; | |
5242 GtkWidget *tmp; | |
5243 | |
5244 DW_MUTEX_LOCK; | |
5245 tmp = gtk_drawing_area_new(); | |
5246 gtk_widget_set_events(tmp, GDK_EXPOSURE_MASK | |
5247 | GDK_LEAVE_NOTIFY_MASK | |
5248 | 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
|
5249 | GDK_KEY_PRESS_MASK |
3 | 5250 | GDK_POINTER_MOTION_MASK |
5251 | 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
|
5252 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
|
5253 GTK_WIDGET_SET_FLAGS(tmp, GTK_CAN_FOCUS); |
3 | 5254 gtk_widget_show(tmp); |
5255 DW_MUTEX_UNLOCK; | |
5256 return tmp; | |
5257 } | |
5258 | |
193
efd4703450fa
Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
185
diff
changeset
|
5259 /* 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
|
5260 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
|
5261 { |
efd4703450fa
Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
185
diff
changeset
|
5262 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
|
5263 { |
efd4703450fa
Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
185
diff
changeset
|
5264 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
|
5265 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
|
5266 } |
372
3ef2cf70ee07
Code for drawing text with a background color on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
369
diff
changeset
|
5267 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
|
5268 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
|
5269 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
|
5270 } |
efd4703450fa
Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
185
diff
changeset
|
5271 |
3 | 5272 /* Sets the current foreground drawing color. |
5273 * Parameters: | |
5274 * red: red value. | |
5275 * green: green value. | |
5276 * blue: blue value. | |
5277 */ | |
5278 void dw_color_foreground_set(unsigned long value) | |
5279 { | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5280 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
|
5281 GdkColor color = _internal_color(value); |
3 | 5282 |
5283 DW_MUTEX_LOCK; | |
373
d04b0699fc28
Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
372
diff
changeset
|
5284 gdk_color_alloc(_dw_cmap, &color); |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5285 _foreground[index] = color; |
3 | 5286 DW_MUTEX_UNLOCK; |
5287 } | |
5288 | |
5289 /* Sets the current background drawing color. | |
5290 * Parameters: | |
5291 * red: red value. | |
5292 * green: green value. | |
5293 * blue: blue value. | |
5294 */ | |
5295 void dw_color_background_set(unsigned long value) | |
5296 { | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5297 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
|
5298 GdkColor color = _internal_color(value); |
3 | 5299 |
5300 DW_MUTEX_LOCK; | |
373
d04b0699fc28
Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
372
diff
changeset
|
5301 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
|
5302 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
|
5303 _transparent[index] = 1; |
d04b0699fc28
Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
372
diff
changeset
|
5304 else |
d04b0699fc28
Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
372
diff
changeset
|
5305 _transparent[index] = 0; |
d04b0699fc28
Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
372
diff
changeset
|
5306 |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5307 _background[index] = color; |
3 | 5308 DW_MUTEX_UNLOCK; |
5309 } | |
5310 | |
5311 GdkGC *_set_colors(GdkWindow *window) | |
5312 { | |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5313 GdkGC *gc = NULL; |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5314 int index = _find_thread_index(dw_thread_id()); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5315 |
3 | 5316 if(!window) |
5317 return NULL; | |
5318 gc = gdk_gc_new(window); | |
5319 if(gc) | |
5320 { | |
373
d04b0699fc28
Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
372
diff
changeset
|
5321 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
|
5322 gdk_gc_set_background(gc, &_background[index]); |
3 | 5323 } |
5324 return gc; | |
5325 } | |
5326 | |
5327 /* Draw a point on a window (preferably a render window). | |
5328 * Parameters: | |
5329 * handle: Handle to the window. | |
5330 * pixmap: Handle to the pixmap. (choose only one of these) | |
5331 * x: X coordinate. | |
5332 * y: Y coordinate. | |
5333 */ | |
5334 void dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y) | |
5335 { | |
5336 int _locked_by_me = FALSE; | |
5337 GdkGC *gc = NULL; | |
5338 | |
5339 DW_MUTEX_LOCK; | |
5340 if(handle) | |
5341 gc = _set_colors(handle->window); | |
5342 else if(pixmap) | |
5343 gc = _set_colors(pixmap->pixmap); | |
5344 if(gc) | |
5345 { | |
5346 gdk_draw_point(handle ? handle->window : pixmap->pixmap, gc, x, y); | |
5347 gdk_gc_unref(gc); | |
5348 } | |
5349 DW_MUTEX_UNLOCK; | |
5350 } | |
5351 | |
5352 /* Draw a line on a window (preferably a render window). | |
5353 * Parameters: | |
5354 * handle: Handle to the window. | |
5355 * pixmap: Handle to the pixmap. (choose only one of these) | |
5356 * x1: First X coordinate. | |
5357 * y1: First Y coordinate. | |
5358 * x2: Second X coordinate. | |
5359 * y2: Second Y coordinate. | |
5360 */ | |
5361 void dw_draw_line(HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2) | |
5362 { | |
5363 int _locked_by_me = FALSE; | |
5364 GdkGC *gc = NULL; | |
5365 | |
5366 DW_MUTEX_LOCK; | |
5367 if(handle) | |
5368 gc = _set_colors(handle->window); | |
5369 else if(pixmap) | |
5370 gc = _set_colors(pixmap->pixmap); | |
5371 if(gc) | |
5372 { | |
5373 gdk_draw_line(handle ? handle->window : pixmap->pixmap, gc, x1, y1, x2, y2); | |
5374 gdk_gc_unref(gc); | |
5375 } | |
5376 DW_MUTEX_UNLOCK; | |
5377 } | |
5378 | |
5379 /* Draw a rectangle on a window (preferably a render window). | |
5380 * Parameters: | |
5381 * handle: Handle to the window. | |
5382 * pixmap: Handle to the pixmap. (choose only one of these) | |
5383 * x: X coordinate. | |
5384 * y: Y coordinate. | |
5385 * width: Width of rectangle. | |
5386 * height: Height of rectangle. | |
5387 */ | |
5388 void dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height) | |
5389 { | |
5390 int _locked_by_me = FALSE; | |
5391 GdkGC *gc = NULL; | |
5392 | |
5393 DW_MUTEX_LOCK; | |
5394 if(handle) | |
5395 gc = _set_colors(handle->window); | |
5396 else if(pixmap) | |
5397 gc = _set_colors(pixmap->pixmap); | |
5398 if(gc) | |
5399 { | |
5400 gdk_draw_rectangle(handle ? handle->window : pixmap->pixmap, gc, fill, x, y, width, height); | |
5401 gdk_gc_unref(gc); | |
5402 } | |
5403 DW_MUTEX_UNLOCK; | |
5404 } | |
5405 | |
5406 /* Draw text on a window (preferably a render window). | |
5407 * Parameters: | |
5408 * handle: Handle to the window. | |
5409 * pixmap: Handle to the pixmap. (choose only one of these) | |
5410 * x: X coordinate. | |
5411 * y: Y coordinate. | |
5412 * text: Text to be displayed. | |
5413 */ | |
5414 void dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text) | |
5415 { | |
5416 int _locked_by_me = FALSE; | |
5417 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
|
5418 #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
|
5419 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
|
5420 #else |
3 | 5421 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
|
5422 #endif |
3 | 5423 char *fontname = "fixed"; |
5424 | |
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
|
5425 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
|
5426 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
|
5427 |
3 | 5428 DW_MUTEX_LOCK; |
5429 if(handle) | |
5430 { | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5431 fontname = (char *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_fontname"); |
3 | 5432 gc = _set_colors(handle->window); |
5433 } | |
5434 else if(pixmap) | |
5435 { | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5436 fontname = (char *)gtk_object_get_data(GTK_OBJECT(pixmap->handle), "_dw_fontname"); |
3 | 5437 gc = _set_colors(pixmap->pixmap); |
5438 } | |
5439 if(gc) | |
5440 { | |
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
|
5441 #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
|
5442 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
|
5443 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
|
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 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
|
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(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
|
5448 { |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5449 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
|
5450 |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5451 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
|
5452 { |
372
3ef2cf70ee07
Code for drawing text with a background color on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
369
diff
changeset
|
5453 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
|
5454 |
373
d04b0699fc28
Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
372
diff
changeset
|
5455 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
|
5456 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
|
5457 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
|
5458 |
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
|
5459 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
|
5460 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
|
5461 else |
3ef2cf70ee07
Code for drawing text with a background color on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
369
diff
changeset
|
5462 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
|
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 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
|
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 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
|
5467 } |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5468 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
|
5469 } |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5470 #else |
3 | 5471 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
|
5472 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
|
5473 font = gdk_font_load("fixed"); |
3 | 5474 if(font) |
5475 { | |
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
|
5476 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
|
5477 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
|
5478 |
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
|
5479 /* 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
|
5480 * 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
|
5481 * 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
|
5482 */ |
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
|
5483 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
|
5484 /* 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
|
5485 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
|
5486 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
|
5487 { |
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 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
|
5489 |
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 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
|
5491 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
|
5492 { |
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_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
|
5494 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
|
5495 } |
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
|
5496 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
|
5497 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
|
5498 } |
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
|
5499 gdk_draw_text(handle ? handle->window : pixmap->pixmap, font, gc, x, y + ascent + 1, text, strlen(text)); |
3 | 5500 gdk_font_unref(font); |
5501 } | |
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
|
5502 #endif |
149
6028f787f7c8
Fixed a graphics context leak in dw_draw_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
148
diff
changeset
|
5503 gdk_gc_unref(gc); |
3 | 5504 } |
5505 DW_MUTEX_UNLOCK; | |
5506 } | |
5507 | |
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
|
5508 /* 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
|
5509 * 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
|
5510 * 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
|
5511 * 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
|
5512 * 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
|
5513 * 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
|
5514 * 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
|
5515 */ |
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
|
5516 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
|
5517 { |
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 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
|
5519 #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
|
5520 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
|
5521 #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
|
5522 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
|
5523 #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
|
5524 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
|
5525 |
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(!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
|
5527 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
|
5528 |
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
|
5529 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
|
5530 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
|
5531 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
|
5532 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
|
5533 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
|
5534 |
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
|
5535 #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
|
5536 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
|
5537 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
|
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 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
|
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(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
|
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 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
|
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 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
|
5546 { |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5547 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
|
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 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
|
5550 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
|
5551 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
|
5552 |
b479002e013f
Upped the 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 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
|
5554 *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
|
5555 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
|
5556 *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
|
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 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
|
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 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
|
5561 } |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5562 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
|
5563 } |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5564 #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
|
5565 |
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
|
5566 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
|
5567 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
|
5568 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
|
5569 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
|
5570 { |
bf42d08d72d7
Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
48
diff
changeset
|
5571 if(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
|
5572 *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
|
5573 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
|
5574 *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
|
5575 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
|
5576 } |
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
|
5577 #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
|
5578 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
|
5579 } |
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
|
5580 |
3 | 5581 /* |
5582 * Creates a pixmap with given parameters. | |
5583 * Parameters: | |
5584 * handle: Window handle the pixmap is associated with. | |
5585 * width: Width of the pixmap in pixels. | |
5586 * height: Height of the pixmap in pixels. | |
5587 * depth: Color depth of the pixmap. | |
5588 * Returns: | |
5589 * A handle to a pixmap or NULL on failure. | |
5590 */ | |
5591 HPIXMAP dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth) | |
5592 { | |
5593 int _locked_by_me = FALSE; | |
5594 HPIXMAP pixmap; | |
5595 | |
5596 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) | |
5597 return NULL; | |
5598 | |
5599 if (!depth) | |
66
664a274a46a6
Fixed color depth problem when creating a new pixmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
63
diff
changeset
|
5600 depth = -1; |
3 | 5601 |
5602 pixmap->width = width; pixmap->height = height; | |
5603 | |
5604 | |
5605 DW_MUTEX_LOCK; | |
5606 pixmap->handle = handle; | |
5607 pixmap->pixmap = gdk_pixmap_new(handle->window, width, height, depth); | |
5608 DW_MUTEX_UNLOCK; | |
5609 return pixmap; | |
5610 } | |
5611 | |
5612 /* | |
241
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5613 * Creates a pixmap from a file. |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5614 * Parameters: |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5615 * 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
|
5616 * 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
|
5617 * DW pick the appropriate file extension. |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5618 * (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
|
5619 * Returns: |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5620 * 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
|
5621 */ |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5622 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
|
5623 { |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5624 int _locked_by_me = FALSE; |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5625 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
|
5626 #ifndef USE_IMLIB |
241
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5627 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
|
5628 #endif |
241
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5629 #if GTK_MAJOR_VERSION > 1 |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5630 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
|
5631 #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
|
5632 GdkImlibImage *image; |
241
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5633 #endif |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5634 char *file = alloca(strlen(filename) + 5); |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5635 |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5636 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
|
5637 return NULL; |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5638 |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5639 strcpy(file, filename); |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5640 |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5641 /* 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
|
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 /* Try with .xpm extention */ |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5645 strcat(file, ".xpm"); |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5646 if(access(file, 04) != 0) |
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 free(pixmap); |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5649 return NULL; |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5650 } |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5651 } |
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 DW_MUTEX_LOCK; |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5654 #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
|
5655 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
|
5656 |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5657 pixmap->width = gdk_pixbuf_get_width(pixbuf); |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5658 pixmap->height = gdk_pixbuf_get_height(pixbuf); |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5659 |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5660 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
|
5661 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
|
5662 #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
|
5663 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
|
5664 |
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
|
5665 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
|
5666 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
|
5667 |
245
11baf43efbc2
Must call gdk_imlib_render() before gdk_imlib_copy_image().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
244
diff
changeset
|
5668 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
|
5669 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
|
5670 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
|
5671 #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
|
5672 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
|
5673 #endif |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5674 pixmap->handle = handle; |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5675 DW_MUTEX_UNLOCK; |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5676 return pixmap; |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5677 } |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5678 |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5679 /* |
3 | 5680 * Creates a pixmap from internal resource graphic specified by id. |
5681 * Parameters: | |
5682 * handle: Window handle the pixmap is associated with. | |
5683 * id: Resource ID associated with requested pixmap. | |
5684 * Returns: | |
5685 * A handle to a pixmap or NULL on failure. | |
5686 */ | |
5687 HPIXMAP dw_pixmap_grab(HWND handle, ULONG id) | |
5688 { | |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5689 GdkBitmap *bitmap = NULL; |
3 | 5690 HPIXMAP pixmap; |
5691 int _locked_by_me = FALSE; | |
5692 | |
5693 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) | |
5694 return NULL; | |
5695 | |
5696 | |
5697 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
|
5698 pixmap->pixmap = _find_pixmap(&bitmap, id, handle, &pixmap->width, &pixmap->height); |
3 | 5699 if(pixmap->pixmap) |
5700 { | |
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
|
5701 #if GTK_MAJOR_VERSION < 2 |
3 | 5702 GdkPixmapPrivate *pvt = (GdkPixmapPrivate *)pixmap->pixmap; |
5703 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
|
5704 #endif |
3 | 5705 } |
5706 DW_MUTEX_UNLOCK; | |
5707 return pixmap; | |
5708 } | |
5709 | |
5710 /* Call this after drawing to the screen to make sure | |
5711 * anything you have drawn is visible. | |
5712 */ | |
5713 void dw_flush(void) | |
5714 { | |
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
|
5715 #if GTK_MAJOR_VERSION < 2 |
3 | 5716 int _locked_by_me = FALSE; |
5717 | |
5718 DW_MUTEX_LOCK; | |
5719 gdk_flush(); | |
5720 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
|
5721 #endif |
3 | 5722 } |
5723 | |
5724 /* | |
5725 * Destroys an allocated pixmap. | |
5726 * Parameters: | |
5727 * pixmap: Handle to a pixmap returned by | |
5728 * dw_pixmap_new.. | |
5729 */ | |
5730 void dw_pixmap_destroy(HPIXMAP pixmap) | |
5731 { | |
5732 int _locked_by_me = FALSE; | |
5733 | |
5734 DW_MUTEX_LOCK; | |
5735 gdk_pixmap_unref(pixmap->pixmap); | |
5736 free(pixmap); | |
5737 DW_MUTEX_UNLOCK; | |
5738 } | |
5739 | |
5740 /* | |
5741 * Copies from one item to another. | |
5742 * Parameters: | |
5743 * dest: Destination window handle. | |
5744 * destp: Destination pixmap. (choose only one). | |
5745 * xdest: X coordinate of destination. | |
5746 * ydest: Y coordinate of destination. | |
5747 * width: Width of area to copy. | |
5748 * height: Height of area to copy. | |
5749 * src: Source window handle. | |
5750 * srcp: Source pixmap. (choose only one). | |
5751 * xsrc: X coordinate of source. | |
5752 * ysrc: Y coordinate of source. | |
5753 */ | |
5754 void dw_pixmap_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc) | |
5755 { | |
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
|
5756 /* 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
|
5757 * 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
|
5758 * 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
|
5759 * 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
|
5760 */ |
3 | 5761 int _locked_by_me = FALSE; |
5762 GdkGC *gc = NULL; | |
5763 | |
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
|
5764 if((!dest && (!destp || !destp->pixmap)) || (!src && (!srcp || !srcp->pixmap))) |
3 | 5765 return; |
5766 | |
5767 DW_MUTEX_LOCK; | |
5768 if(dest) | |
5769 gc = _set_colors(dest->window); | |
5770 else if(src) | |
5771 gc = _set_colors(src->window); | |
5772 else if(destp) | |
5773 gc = gdk_gc_new(destp->pixmap); | |
5774 else if(srcp) | |
5775 gc = gdk_gc_new(srcp->pixmap); | |
122
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
5776 |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
5777 if(gc) |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
5778 { |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
5779 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
|
5780 gdk_gc_unref(gc); |
3 | 5781 } |
5782 DW_MUTEX_UNLOCK; | |
5783 } | |
5784 | |
5785 /* | |
5786 * Emits a beep. | |
5787 * Parameters: | |
5788 * freq: Frequency. | |
5789 * dur: Duration. | |
5790 */ | |
5791 void dw_beep(int freq, int dur) | |
5792 { | |
5793 int _locked_by_me = FALSE; | |
5794 | |
5795 DW_MUTEX_LOCK; | |
5796 gdk_beep(); | |
5797 DW_MUTEX_UNLOCK; | |
5798 } | |
5799 | |
157
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5800 void _my_strlwr(char *buf) |
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 int z, len = strlen(buf); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5803 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5804 for(z=0;z<len;z++) |
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 if(buf[z] >= 'A' && buf[z] <= 'Z') |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5807 buf[z] -= 'A' - 'a'; |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5808 } |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5809 } |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5810 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5811 /* Open a shared library and return a handle. |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5812 * Parameters: |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5813 * name: Base name of the shared library. |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5814 * handle: Pointer to a module handle, |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5815 * will be filled in with the handle. |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5816 */ |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5817 int dw_module_load(char *name, HMOD *handle) |
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 int len; |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5820 char *newname; |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5821 char errorbuf[1024]; |
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 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5824 if(!handle) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5825 return -1; |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5826 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5827 if((len = strlen(name)) == 0) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5828 return -1; |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5829 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5830 /* Lenth + "lib" + ".so" + NULL */ |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5831 newname = malloc(len + 7); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5832 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5833 if(!newname) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5834 return -1; |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5835 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5836 sprintf(newname, "lib%s.so", name); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5837 _my_strlwr(newname); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5838 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5839 *handle = dlopen(newname, RTLD_NOW); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5840 if(*handle == NULL) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5841 { |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5842 strncpy(errorbuf, dlerror(), 1024); |
164
d35771f70bdd
Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
163
diff
changeset
|
5843 printf("%s\n", errorbuf); |
157
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5844 sprintf(newname, "lib%s.so", name); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5845 *handle = dlopen(newname, RTLD_NOW); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5846 } |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5847 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5848 free(newname); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5849 |
163
0322836c5299
Return -1 on error from dw_module_load().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
162
diff
changeset
|
5850 return (NULL == *handle) ? -1 : 0; |
157
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5851 } |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5852 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5853 /* Queries the address of a symbol within open handle. |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5854 * Parameters: |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5855 * handle: Module handle returned by dw_module_load() |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5856 * name: Name of the symbol you want the address of. |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5857 * func: A pointer to a function pointer, to obtain |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5858 * the address. |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5859 */ |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5860 int dw_module_symbol(HMOD handle, char *name, void**func) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5861 { |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5862 if(!func || !name) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5863 return -1; |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5864 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5865 if(strlen(name) == 0) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5866 return -1; |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5867 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5868 *func = (void*)dlsym(handle, name); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5869 return (NULL == *func); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5870 } |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5871 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5872 /* Frees the shared library previously opened. |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5873 * Parameters: |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5874 * handle: Module handle returned by dw_module_load() |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5875 */ |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5876 int dw_module_close(HMOD handle) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5877 { |
162
df59a3fc6de6
Fixed a minor bug in dw_module_close().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
157
diff
changeset
|
5878 if(handle) |
df59a3fc6de6
Fixed a minor bug in dw_module_close().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
157
diff
changeset
|
5879 return dlclose(handle); |
df59a3fc6de6
Fixed a minor bug in dw_module_close().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
157
diff
changeset
|
5880 return 0; |
157
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5881 } |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5882 |
3 | 5883 /* |
5884 * Returns the handle to an unnamed mutex semaphore. | |
5885 */ | |
5886 HMTX dw_mutex_new(void) | |
5887 { | |
239
403b07f873e1
Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
237
diff
changeset
|
5888 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
|
5889 |
403b07f873e1
Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
237
diff
changeset
|
5890 pthread_mutex_init(mutex, NULL); |
3 | 5891 return mutex; |
5892 } | |
5893 | |
5894 /* | |
5895 * Closes a semaphore created by dw_mutex_new(). | |
5896 * Parameters: | |
5897 * mutex: The handle to the mutex returned by dw_mutex_new(). | |
5898 */ | |
5899 void dw_mutex_close(HMTX mutex) | |
5900 { | |
239
403b07f873e1
Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
237
diff
changeset
|
5901 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
|
5902 { |
403b07f873e1
Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
237
diff
changeset
|
5903 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
|
5904 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
|
5905 } |
3 | 5906 } |
5907 | |
5908 /* | |
5909 * Tries to gain access to the semaphore, if it can't it blocks. | |
5910 * Parameters: | |
5911 * mutex: The handle to the mutex returned by dw_mutex_new(). | |
5912 */ | |
5913 void dw_mutex_lock(HMTX mutex) | |
5914 { | |
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
|
5915 /* 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
|
5916 * 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
|
5917 */ |
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 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
|
5919 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
|
5920 |
239
403b07f873e1
Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
237
diff
changeset
|
5921 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
|
5922 |
baaf4b04d284
Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
94
diff
changeset
|
5923 /* 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
|
5924 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
|
5925 gdk_threads_enter(); |
3 | 5926 } |
5927 | |
5928 /* | |
5929 * Reliquishes the access to the semaphore. | |
5930 * Parameters: | |
5931 * mutex: The handle to the mutex returned by dw_mutex_new(). | |
5932 */ | |
5933 void dw_mutex_unlock(HMTX mutex) | |
5934 { | |
239
403b07f873e1
Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
237
diff
changeset
|
5935 pthread_mutex_unlock(mutex); |
3 | 5936 } |
5937 | |
5938 /* | |
5939 * Returns the handle to an unnamed event semaphore. | |
5940 */ | |
5941 HEV dw_event_new(void) | |
5942 { | |
5943 HEV eve = (HEV)malloc(sizeof(struct _dw_unix_event)); | |
5944 | |
5945 if(!eve) | |
5946 return NULL; | |
5947 | |
5948 /* We need to be careful here, mutexes on Linux are | |
5949 * FAST by default but are error checking on other | |
5950 * systems such as FreeBSD and OS/2, perhaps others. | |
5951 */ | |
5952 pthread_mutex_init (&(eve->mutex), NULL); | |
5953 pthread_mutex_lock (&(eve->mutex)); | |
5954 pthread_cond_init (&(eve->event), NULL); | |
5955 | |
5956 pthread_mutex_unlock (&(eve->mutex)); | |
5957 eve->alive = 1; | |
5958 eve->posted = 0; | |
5959 | |
5960 return eve; | |
5961 } | |
5962 | |
5963 /* | |
5964 * Resets a semaphore created by dw_event_new(). | |
5965 * Parameters: | |
5966 * eve: The handle to the event returned by dw_event_new(). | |
5967 */ | |
5968 int dw_event_reset (HEV eve) | |
5969 { | |
5970 if(!eve) | |
5971 return FALSE; | |
5972 | |
5973 pthread_mutex_lock (&(eve->mutex)); | |
5974 pthread_cond_broadcast (&(eve->event)); | |
5975 pthread_cond_init (&(eve->event), NULL); | |
5976 eve->posted = 0; | |
5977 pthread_mutex_unlock (&(eve->mutex)); | |
5978 return 0; | |
5979 } | |
5980 | |
5981 /* | |
5982 * Posts a semaphore created by dw_event_new(). Causing all threads | |
5983 * waiting on this event in dw_event_wait to continue. | |
5984 * Parameters: | |
5985 * eve: The handle to the event returned by dw_event_new(). | |
5986 */ | |
5987 int dw_event_post (HEV eve) | |
5988 { | |
5989 if(!eve) | |
5990 return FALSE; | |
5991 | |
5992 pthread_mutex_lock (&(eve->mutex)); | |
5993 pthread_cond_broadcast (&(eve->event)); | |
5994 eve->posted = 1; | |
5995 pthread_mutex_unlock (&(eve->mutex)); | |
5996 return 0; | |
5997 } | |
5998 | |
5999 /* | |
6000 * Waits on a semaphore created by dw_event_new(), until the | |
6001 * event gets posted or until the timeout expires. | |
6002 * Parameters: | |
6003 * eve: The handle to the event returned by dw_event_new(). | |
6004 */ | |
6005 int dw_event_wait(HEV eve, unsigned long timeout) | |
6006 { | |
6007 int rc; | |
6008 struct timeval now; | |
6009 struct timespec timeo; | |
6010 | |
6011 if(!eve) | |
6012 return FALSE; | |
6013 | |
6014 if(eve->posted) | |
6015 return 0; | |
6016 | |
6017 pthread_mutex_lock (&(eve->mutex)); | |
6018 gettimeofday(&now, 0); | |
6019 timeo.tv_sec = now.tv_sec + (timeout / 1000); | |
6020 timeo.tv_nsec = now.tv_usec * 1000; | |
6021 rc = pthread_cond_timedwait (&(eve->event), &(eve->mutex), &timeo); | |
6022 pthread_mutex_unlock (&(eve->mutex)); | |
6023 if(!rc) | |
6024 return 1; | |
6025 if(rc == ETIMEDOUT) | |
6026 return -1; | |
6027 return 0; | |
6028 } | |
6029 | |
6030 /* | |
6031 * Closes a semaphore created by dw_event_new(). | |
6032 * Parameters: | |
6033 * eve: The handle to the event returned by dw_event_new(). | |
6034 */ | |
6035 int dw_event_close(HEV *eve) | |
6036 { | |
6037 if(!eve || !(*eve)) | |
6038 return FALSE; | |
6039 | |
6040 pthread_mutex_lock (&((*eve)->mutex)); | |
6041 pthread_cond_destroy (&((*eve)->event)); | |
6042 pthread_mutex_unlock (&((*eve)->mutex)); | |
6043 pthread_mutex_destroy (&((*eve)->mutex)); | |
6044 free(*eve); | |
6045 *eve = NULL; | |
6046 | |
6047 return TRUE; | |
6048 } | |
6049 | |
6050 /* | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6051 * Setup thread independent color sets. |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6052 */ |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6053 void _dwthreadstart(void *data) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6054 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6055 void (*threadfunc)(void *) = NULL; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6056 void **tmp = (void **)data; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6057 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6058 threadfunc = (void (*)(void *))tmp[0]; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6059 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6060 _dw_thread_add(dw_thread_id()); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6061 threadfunc(tmp[1]); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6062 _dw_thread_remove(dw_thread_id()); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6063 free(tmp); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6064 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6065 /* |
3 | 6066 * Creates a new thread with a starting point of func. |
6067 * Parameters: | |
6068 * func: Function which will be run in the new thread. | |
6069 * data: Parameter(s) passed to the function. | |
6070 * stack: Stack size of new thread (OS/2 and Windows only). | |
6071 */ | |
6072 DWTID dw_thread_new(void *func, void *data, int stack) | |
6073 { | |
6074 DWTID gtkthread; | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6075 void **tmp = malloc(sizeof(void *) * 2); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6076 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6077 tmp[0] = func; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6078 tmp[1] = data; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6079 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6080 pthread_create(>kthread, NULL, (void *)_dwthreadstart, (void *)tmp); |
3 | 6081 return gtkthread; |
6082 } | |
6083 | |
6084 /* | |
6085 * Ends execution of current thread immediately. | |
6086 */ | |
6087 void dw_thread_end(void) | |
6088 { | |
6089 pthread_exit(NULL); | |
6090 } | |
6091 | |
6092 /* | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6093 * Returns the current thread's ID. |
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 DWTID dw_thread_id(void) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6096 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6097 return (DWTID)pthread_self(); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6098 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6099 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6100 /* |
3 | 6101 * Cleanly terminates a DW session, should be signal handler safe. |
6102 * Parameters: | |
6103 * exitcode: Exit code reported to the operating system. | |
6104 */ | |
6105 void dw_exit(int exitcode) | |
6106 { | |
6107 exit(exitcode); | |
6108 } | |
6109 | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6110 #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
|
6111 |
3 | 6112 /* |
6113 * Pack windows (widgets) into a box from the end (or bottom). | |
6114 * Parameters: | |
6115 * box: Window handle of the box to be packed into. | |
6116 * item: Window handle of the item to be back. | |
6117 * width: Width in pixels of the item or -1 to be self determined. | |
6118 * height: Height in pixels of the item or -1 to be self determined. | |
6119 * hsize: TRUE if the window (widget) should expand horizontally to fill space given. | |
6120 * vsize: TRUE if the window (widget) should expand vertically to fill space given. | |
6121 * pad: Number of pixels of padding around the item. | |
6122 */ | |
6123 void dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) | |
6124 { | |
6125 int _locked_by_me = FALSE; | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6126 GtkWidget *tmp; |
3 | 6127 |
6128 if(!box) | |
6129 return; | |
6130 | |
6131 DW_MUTEX_LOCK; | |
6132 | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6133 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
|
6134 box = tmp; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6135 |
3 | 6136 if(!item) |
6137 { | |
6138 item = gtk_label_new(""); | |
6139 gtk_widget_show(item); | |
6140 } | |
6141 | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6142 if(GTK_IS_TABLE(box)) |
3 | 6143 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6144 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
|
6145 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
|
6146 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6147 /* 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
|
6148 * 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
|
6149 * 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
|
6150 * 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
|
6151 */ |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6152 if(GTK_IS_TABLE(item)) |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6153 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6154 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
|
6155 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6156 if(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 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
|
6159 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
|
6160 item = eventbox; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6161 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6162 } |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6163 |
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
|
6164 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
|
6165 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
|
6166 else |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6167 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
|
6168 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6169 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
|
6170 gtk_object_set_data(GTK_OBJECT(box), "_dw_boxcount", (gpointer)boxcount + 1); |
3 | 6171 gtk_widget_set_usize(item, width, height); |
6172 if(GTK_IS_RADIO_BUTTON(item)) | |
6173 { | |
6174 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
|
6175 GtkWidget *groupstart = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(box), "_dw_group"); |
3 | 6176 |
6177 if(groupstart) | |
6178 { | |
6179 group = gtk_radio_button_group(GTK_RADIO_BUTTON(groupstart)); | |
6180 gtk_radio_button_set_group(GTK_RADIO_BUTTON(item), group); | |
6181 } | |
6182 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
|
6183 gtk_object_set_data(GTK_OBJECT(box), "_dw_group", (gpointer)item); |
3 | 6184 } |
6185 } | |
6186 else | |
6187 { | |
6188 GtkWidget *vbox = gtk_vbox_new(FALSE, 0); | |
6189 | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6190 if(GTK_IS_TABLE(item)) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6191 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6192 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
|
6193 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6194 if(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 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
|
6197 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
|
6198 item = eventbox; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6199 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6200 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6201 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6202 gtk_container_border_width(GTK_CONTAINER(box), pad); |
3 | 6203 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
|
6204 gtk_box_pack_end(GTK_BOX(vbox), item, TRUE, TRUE, 0); |
3 | 6205 gtk_widget_show(vbox); |
6206 | |
6207 gtk_widget_set_usize(item, width, height); | |
6208 gtk_object_set_user_data(GTK_OBJECT(box), vbox); | |
6209 } | |
6210 DW_MUTEX_UNLOCK; | |
6211 } | |
6212 | |
6213 /* | |
6214 * Sets the size of a given window (widget). | |
6215 * Parameters: | |
6216 * handle: Window (widget) handle. | |
6217 * width: New width in pixels. | |
6218 * height: New height in pixels. | |
6219 */ | |
6220 void dw_window_set_usize(HWND handle, unsigned long width, unsigned long height) | |
6221 { | |
6222 int _locked_by_me = FALSE; | |
6223 | |
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
|
6224 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
|
6225 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
|
6226 |
3 | 6227 DW_MUTEX_LOCK; |
6228 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
|
6229 { |
3 | 6230 _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
|
6231 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
|
6232 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
|
6233 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
|
6234 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
|
6235 { |
49ac97060328
Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
271
diff
changeset
|
6236 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
|
6237 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
|
6238 } |
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
|
6239 } |
3 | 6240 else |
6241 gtk_widget_set_usize(handle, width, height); | |
6242 DW_MUTEX_UNLOCK; | |
6243 } | |
6244 | |
6245 /* | |
6246 * Returns the width of the screen. | |
6247 */ | |
6248 int dw_screen_width(void) | |
6249 { | |
6250 int retval; | |
6251 int _locked_by_me = FALSE; | |
6252 | |
6253 DW_MUTEX_LOCK; | |
6254 retval = gdk_screen_width(); | |
6255 DW_MUTEX_UNLOCK; | |
6256 return retval; | |
6257 } | |
6258 | |
6259 /* | |
6260 * Returns the height of the screen. | |
6261 */ | |
6262 int dw_screen_height(void) | |
6263 { | |
6264 int retval; | |
6265 int _locked_by_me = FALSE; | |
6266 | |
6267 DW_MUTEX_UNLOCK; | |
6268 retval = gdk_screen_height(); | |
6269 DW_MUTEX_UNLOCK; | |
6270 return retval; | |
6271 } | |
6272 | |
6273 /* This should return the current color depth */ | |
6274 unsigned long dw_color_depth(void) | |
6275 { | |
6276 int retval; | |
6277 int _locked_by_me = FALSE; | |
6278 | |
6279 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
|
6280 retval = gdk_visual_get_best_depth(); |
3 | 6281 DW_MUTEX_UNLOCK; |
6282 return retval; | |
6283 } | |
6284 | |
6285 /* | |
6286 * Sets the position of a given window (widget). | |
6287 * Parameters: | |
6288 * handle: Window (widget) handle. | |
6289 * x: X location from the bottom left. | |
6290 * y: Y location from the bottom left. | |
6291 */ | |
6292 void dw_window_set_pos(HWND handle, unsigned long x, unsigned long y) | |
6293 { | |
6294 int _locked_by_me = FALSE; | |
6295 | |
6296 DW_MUTEX_LOCK; | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
6297 if(handle && handle->window) |
3 | 6298 gdk_window_move(handle->window, x, y); |
6299 DW_MUTEX_UNLOCK; | |
6300 } | |
6301 | |
6302 /* | |
6303 * Sets the position and size of a given window (widget). | |
6304 * Parameters: | |
6305 * handle: Window (widget) handle. | |
6306 * x: X location from the bottom left. | |
6307 * y: Y location from the bottom left. | |
6308 * width: Width of the widget. | |
6309 * height: Height of the widget. | |
6310 */ | |
6311 void dw_window_set_pos_size(HWND handle, unsigned long x, unsigned long y, unsigned long width, unsigned long height) | |
6312 { | |
6313 int _locked_by_me = FALSE; | |
6314 | |
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
|
6315 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
|
6316 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
|
6317 |
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
|
6318 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
|
6319 if(GTK_IS_WINDOW(handle)) |
3 | 6320 { |
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
|
6321 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
|
6322 gtk_widget_set_uposition(handle, x, y); |
3 | 6323 } |
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
|
6324 else if(handle->window) |
3 | 6325 { |
6326 gdk_window_resize(handle->window, width, height); | |
6327 gdk_window_move(handle->window, x, y); | |
6328 } | |
6329 DW_MUTEX_UNLOCK; | |
6330 } | |
6331 | |
6332 /* | |
6333 * Gets the position and size of a given window (widget). | |
6334 * Parameters: | |
6335 * handle: Window (widget) handle. | |
6336 * x: X location from the bottom left. | |
6337 * y: Y location from the bottom left. | |
6338 * width: Width of the widget. | |
6339 * height: Height of the widget. | |
6340 */ | |
6341 void dw_window_get_pos_size(HWND handle, ULONG *x, ULONG *y, ULONG *width, ULONG *height) | |
6342 { | |
6343 int _locked_by_me = FALSE; | |
6344 gint gx, gy, gwidth, gheight, gdepth; | |
6345 | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
6346 if(handle && handle->window) |
3 | 6347 { |
6348 DW_MUTEX_LOCK; | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
6349 |
3 | 6350 gdk_window_get_geometry(handle->window, &gx, &gy, &gwidth, &gheight, &gdepth); |
6351 gdk_window_get_root_origin(handle->window, &gx, &gy); | |
6352 if(x) | |
6353 *x = gx; | |
6354 if(y) | |
6355 *y = gy; | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6356 if(GTK_IS_WINDOW(handle)) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6357 { |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6358 if(width) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6359 *width = gwidth + _dw_border_width; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6360 if(height) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6361 *height = gheight + _dw_border_height; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6362 } |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6363 else |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6364 { |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6365 if(width) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6366 *width = gwidth; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6367 if(height) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6368 *height = gheight; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6369 } |
3 | 6370 DW_MUTEX_UNLOCK; |
6371 } | |
6372 } | |
6373 | |
6374 /* | |
6375 * Sets the style of a given window (widget). | |
6376 * Parameters: | |
6377 * handle: Window (widget) handle. | |
6378 * width: New width in pixels. | |
6379 * height: New height in pixels. | |
6380 */ | |
6381 void dw_window_set_style(HWND handle, unsigned long style, unsigned long mask) | |
6382 { | |
6383 GtkWidget *handle2 = handle; | |
6384 int _locked_by_me = FALSE; | |
6385 | |
6386 DW_MUTEX_LOCK; | |
6387 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
6388 { | |
6389 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
6390 if(tmp) | |
6391 handle2 = tmp; | |
6392 } | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6393 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
|
6394 { |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6395 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
|
6396 { |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6397 gfloat x, y; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6398 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6399 x = y = DW_LEFT; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6400 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6401 if(style & DW_DT_CENTER) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6402 x = DW_CENTER; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6403 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6404 if(style & DW_DT_VCENTER) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6405 y = DW_CENTER; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6406 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6407 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
|
6408 } |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6409 if(style & DW_DT_WORDBREAK) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6410 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
|
6411 } |
3 | 6412 DW_MUTEX_UNLOCK; |
6413 } | |
6414 | |
6415 /* | |
6416 * Adds a new page to specified notebook. | |
6417 * Parameters: | |
6418 * handle: Window (widget) handle. | |
6419 * flags: Any additional page creation flags. | |
6420 * front: If TRUE page is added at the beginning. | |
6421 */ | |
6422 unsigned long dw_notebook_page_new(HWND handle, unsigned long flags, int front) | |
6423 { | |
6424 int z; | |
6425 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
|
6426 GtkWidget **pagearray; |
3 | 6427 |
6428 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
|
6429 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
|
6430 |
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) |
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 for(z=0;z<256;z++) |
3 | 6434 { |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6435 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
|
6436 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6437 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
|
6438 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
|
6439 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6440 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
|
6441 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
|
6442 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6443 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
|
6444 /* 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
|
6445 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
|
6446 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
|
6447 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
|
6448 } |
3 | 6449 } |
15
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
6450 } |
3 | 6451 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
|
6452 |
3 | 6453 /* Hopefully this won't happen. */ |
6454 return 256; | |
6455 } | |
6456 | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6457 /* 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
|
6458 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
|
6459 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6460 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
|
6461 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
|
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(pagearray) |
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 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
|
6466 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6467 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
|
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 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
|
6470 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
|
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 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6473 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6474 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
|
6475 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6476 |
3 | 6477 /* |
6478 * Remove a page from a notebook. | |
6479 * Parameters: | |
6480 * handle: Handle to the notebook widget. | |
6481 * pageid: ID of the page to be destroyed. | |
6482 */ | |
6483 void dw_notebook_page_destroy(HWND handle, unsigned int pageid) | |
6484 { | |
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 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
|
6486 GtkWidget **pagearray; |
3 | 6487 |
6488 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
|
6489 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
|
6490 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
|
6491 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6492 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
|
6493 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
|
6494 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
|
6495 } |
3 | 6496 DW_MUTEX_UNLOCK; |
6497 } | |
6498 | |
6499 /* | |
6500 * Queries the currently visible page ID. | |
6501 * Parameters: | |
6502 * handle: Handle to the notebook widget. | |
6503 */ | |
346
81fae15885d7
Implemented switch-page on OS/2, and changed the signal prototype to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
345
diff
changeset
|
6504 unsigned long dw_notebook_page_query(HWND handle) |
3 | 6505 { |
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 int retval, phys; |
3 | 6507 int _locked_by_me = FALSE; |
6508 | |
6509 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
|
6510 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
|
6511 retval = _get_logical_page(handle, phys); |
3 | 6512 DW_MUTEX_UNLOCK; |
6513 return retval; | |
6514 } | |
6515 | |
6516 /* | |
6517 * Sets the currently visibale page ID. | |
6518 * Parameters: | |
6519 * handle: Handle to the notebook widget. | |
6520 * pageid: ID of the page to be made visible. | |
6521 */ | |
6522 void dw_notebook_page_set(HWND handle, unsigned int pageid) | |
6523 { | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6524 int realpage, _locked_by_me = FALSE; |
3 | 6525 |
6526 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
|
6527 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
|
6528 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
|
6529 gtk_notebook_set_page(GTK_NOTEBOOK(handle), pageid); |
3 | 6530 DW_MUTEX_UNLOCK; |
6531 } | |
6532 | |
6533 | |
6534 /* | |
6535 * Sets the text on the specified notebook tab. | |
6536 * Parameters: | |
6537 * handle: Notebook handle. | |
6538 * pageid: Page ID of the tab to set. | |
6539 * text: Pointer to the text to set. | |
6540 */ | |
6541 void dw_notebook_page_set_text(HWND handle, unsigned long pageid, char *text) | |
6542 { | |
6543 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
|
6544 int realpage, _locked_by_me = FALSE; |
3 | 6545 |
6546 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
|
6547 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
|
6548 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
|
6549 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6550 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
|
6551 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
|
6552 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6553 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
|
6554 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
|
6555 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
|
6556 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6557 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6558 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
|
6559 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6560 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
|
6561 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
|
6562 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
|
6563 } |
3 | 6564 DW_MUTEX_UNLOCK; |
6565 } | |
6566 | |
6567 /* | |
6568 * Sets the text on the specified notebook tab status area. | |
6569 * Parameters: | |
6570 * handle: Notebook handle. | |
6571 * pageid: Page ID of the tab to set. | |
6572 * text: Pointer to the text to set. | |
6573 */ | |
6574 void dw_notebook_page_set_status_text(HWND handle, unsigned long pageid, char *text) | |
6575 { | |
6576 /* TODO (if possible) */ | |
6577 } | |
6578 | |
6579 /* | |
6580 * Packs the specified box into the notebook page. | |
6581 * Parameters: | |
6582 * handle: Handle to the notebook to be packed. | |
6583 * pageid: Page ID in the notebook which is being packed. | |
6584 * page: Box handle to be packed. | |
6585 */ | |
6586 void dw_notebook_pack(HWND handle, unsigned long pageid, HWND page) | |
6587 { | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6588 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
|
6589 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
|
6590 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
|
6591 char ptext[100]; |
3 | 6592 |
6593 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
|
6594 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
|
6595 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
|
6596 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
|
6597 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
|
6598 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6599 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
|
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 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
|
6602 return; |
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 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6605 /* 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
|
6606 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
|
6607 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6608 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
|
6609 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6610 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
|
6611 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
|
6612 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6613 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
|
6614 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
|
6615 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
|
6616 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
|
6617 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
|
6618 break; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6619 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6620 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6621 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6622 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6623 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
|
6624 |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
6625 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
|
6626 |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6627 if(GTK_IS_TABLE(page)) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6628 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6629 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
|
6630 gtk_container_border_width(GTK_CONTAINER(page), pad); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6631 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6632 |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6633 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
|
6634 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
|
6635 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
|
6636 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
|
6637 else |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6638 gtk_notebook_insert_page(GTK_NOTEBOOK(handle), page, label, 256); |
3 | 6639 DW_MUTEX_UNLOCK; |
6640 } | |
6641 | |
6642 /* | |
6643 * Appends the specified text to the listbox's (or combobox) entry list. | |
6644 * Parameters: | |
6645 * handle: Handle to the listbox to be appended to. | |
6646 * text: Text to append into listbox. | |
6647 */ | |
6648 void dw_listbox_append(HWND handle, char *text) | |
6649 { | |
6650 GtkWidget *handle2 = handle; | |
6651 int _locked_by_me = FALSE; | |
6652 | |
6653 DW_MUTEX_LOCK; | |
6654 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
6655 { | |
6656 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
6657 if(tmp) | |
6658 handle2 = tmp; | |
6659 } | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6660 gtk_object_set_data(GTK_OBJECT(handle), "_dw_appending", (gpointer)1); |
3 | 6661 if(GTK_IS_LIST(handle2)) |
6662 { | |
6663 GtkWidget *list_item; | |
6664 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
|
6665 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
|
6666 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
|
6667 GdkColor *back = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle2), "_dw_backgdk"); |
3 | 6668 |
6669 list_item=gtk_list_item_new_with_label(text); | |
6670 | |
6671 if(font) | |
6672 _set_font(GTK_LIST_ITEM(list_item)->item.bin.child, font); | |
6673 if(fore && back) | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
6674 _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
|
6675 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
|
6676 DW_RGB(back->red, back->green, back->blue)); |
3 | 6677 |
6678 tmp = g_list_append(NULL, list_item); | |
6679 gtk_widget_show(list_item); | |
6680 gtk_list_append_items(GTK_LIST(handle2),tmp); | |
6681 } | |
6682 else if(GTK_IS_COMBO(handle2)) | |
6683 { | |
6684 GList *tmp = (GList *)gtk_object_get_user_data(GTK_OBJECT(handle2)); | |
6685 char *addtext = strdup(text); | |
6686 | |
6687 if(addtext) | |
6688 { | |
6689 tmp = g_list_append(tmp, addtext); | |
6690 gtk_object_set_user_data(GTK_OBJECT(handle2), tmp); | |
6691 gtk_combo_set_popdown_strings(GTK_COMBO(handle2), tmp); | |
6692 } | |
6693 } | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6694 gtk_object_set_data(GTK_OBJECT(handle), "_dw_appending", NULL); |
3 | 6695 DW_MUTEX_UNLOCK; |
6696 } | |
6697 | |
6698 /* | |
6699 * Clears the listbox's (or combobox) list of all entries. | |
6700 * Parameters: | |
6701 * handle: Handle to the listbox to be cleared. | |
6702 */ | |
6703 void dw_listbox_clear(HWND handle) | |
6704 { | |
6705 GtkWidget *handle2 = handle; | |
6706 int _locked_by_me = FALSE; | |
6707 | |
6708 DW_MUTEX_LOCK; | |
6709 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
6710 { | |
6711 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
6712 if(tmp) | |
6713 handle2 = tmp; | |
6714 } | |
6715 if(GTK_IS_COMBO(handle2)) | |
6716 { | |
6717 GList *list, *tmp = (GList *)gtk_object_get_user_data(GTK_OBJECT(handle2)); | |
6718 | |
6719 if(tmp) | |
6720 { | |
6721 list = tmp; | |
6722 while(list) | |
6723 { | |
6724 if(list->data) | |
6725 free(list->data); | |
6726 list=list->next; | |
6727 } | |
6728 g_list_free(tmp); | |
6729 } | |
6730 gtk_object_set_user_data(GTK_OBJECT(handle2), NULL); | |
6731 } | |
6732 else if(GTK_IS_LIST(handle2)) | |
6733 { | |
6734 int count = dw_listbox_count(handle); | |
6735 | |
6736 gtk_list_clear_items(GTK_LIST(handle2), 0, count - 1); | |
6737 } | |
6738 DW_MUTEX_UNLOCK; | |
6739 } | |
6740 | |
6741 /* | |
6742 * Returns the listbox's item count. | |
6743 * Parameters: | |
6744 * handle: Handle to the listbox to be counted | |
6745 */ | |
6746 int dw_listbox_count(HWND handle) | |
6747 { | |
6748 GtkWidget *handle2 = handle; | |
6749 int retval = 0; | |
6750 int _locked_by_me = FALSE; | |
6751 | |
6752 DW_MUTEX_LOCK; | |
6753 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
6754 { | |
6755 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
6756 if(tmp) | |
6757 handle2 = tmp; | |
6758 } | |
6759 else if(GTK_IS_COMBO(handle)) | |
6760 { | |
6761 handle2 = GTK_COMBO(handle)->list; | |
6762 } | |
6763 if(GTK_IS_LIST(handle2)) | |
6764 { | |
6765 GList *list = GTK_LIST(handle2)->children; | |
6766 while(list) | |
6767 { | |
6768 list = list->next; | |
6769 retval++; | |
6770 } | |
6771 } | |
6772 DW_MUTEX_UNLOCK; | |
6773 return retval; | |
6774 } | |
6775 | |
6776 /* | |
6777 * Sets the topmost item in the viewport. | |
6778 * Parameters: | |
6779 * handle: Handle to the listbox to be cleared. | |
6780 * top: Index to the top item. | |
6781 */ | |
6782 void dw_listbox_set_top(HWND handle, int top) | |
6783 { | |
6784 GtkWidget *handle2 = handle; | |
6785 int _locked_by_me = FALSE; | |
6786 | |
6787 DW_MUTEX_LOCK; | |
6788 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
6789 { | |
6790 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
6791 if(tmp) | |
6792 handle2 = tmp; | |
6793 } | |
6794 if(GTK_IS_LIST(handle2)) | |
6795 { | |
6796 int count = dw_listbox_count(handle); | |
6797 GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(handle)); | |
6798 float pos, ratio; | |
6799 | |
6800 if(count) | |
6801 { | |
6802 ratio = (float)top/(float)count; | |
6803 | |
6804 pos = (ratio * (float)(adj->upper - adj->lower)) + adj->lower; | |
6805 | |
6806 gtk_adjustment_set_value(adj, pos); | |
6807 } | |
6808 } | |
6809 DW_MUTEX_UNLOCK; | |
6810 } | |
6811 | |
6812 /* | |
6813 * Copies the given index item's text into buffer. | |
6814 * Parameters: | |
6815 * handle: Handle to the listbox to be queried. | |
6816 * index: Index into the list to be queried. | |
6817 * buffer: Buffer where text will be copied. | |
6818 * length: Length of the buffer (including NULL). | |
6819 */ | |
6820 void dw_listbox_query_text(HWND handle, unsigned int index, char *buffer, unsigned int length) | |
6821 { | |
6822 GtkWidget *handle2 = handle; | |
6823 int _locked_by_me = FALSE; | |
6824 | |
6825 DW_MUTEX_LOCK; | |
6826 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
6827 { | |
6828 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
6829 if(tmp) | |
6830 handle2 = tmp; | |
6831 } | |
6832 else if(GTK_IS_COMBO(handle)) | |
6833 { | |
6834 handle2 = GTK_COMBO(handle)->list; | |
6835 } | |
6836 if(GTK_IS_LIST(handle2)) | |
6837 { | |
6838 int counter = 0; | |
6839 GList *list = GTK_LIST(handle2)->children; | |
6840 | |
6841 while(list) | |
6842 { | |
6843 if(counter == index) | |
6844 { | |
6845 gchar *text = ""; | |
6846 | |
6847 if(GTK_IS_LIST_ITEM(list->data)) | |
6848 { | |
6849 GtkListItem *li = GTK_LIST_ITEM(list->data); | |
6850 | |
6851 if(GTK_IS_ITEM(&(li->item))) | |
6852 { | |
6853 GtkItem *i = &(li->item); | |
6854 | |
6855 if(GTK_IS_BIN(&(i->bin))) | |
6856 { | |
6857 GtkBin *b = &(i->bin); | |
6858 | |
6859 if(GTK_IS_LABEL(b->child)) | |
6860 gtk_label_get(GTK_LABEL(b->child), &text); | |
6861 } | |
6862 } | |
6863 } | |
6864 else if(GTK_IS_COMBO(handle) && list->data) | |
6865 text = (gchar *)list->data; | |
6866 | |
6867 strncpy(buffer, (char *)text, length); | |
6868 break; | |
6869 } | |
6870 list = list->next; | |
6871 counter++; | |
6872 } | |
6873 } | |
6874 DW_MUTEX_UNLOCK; | |
6875 } | |
6876 | |
6877 /* | |
6878 * Sets the text of a given listbox entry. | |
6879 * Parameters: | |
6880 * handle: Handle to the listbox to be queried. | |
6881 * index: Index into the list to be queried. | |
6882 * buffer: Buffer where text will be copied. | |
6883 */ | |
6884 void dw_listbox_set_text(HWND handle, unsigned int index, char *buffer) | |
6885 { | |
6886 GtkWidget *handle2 = handle; | |
6887 int _locked_by_me = FALSE; | |
6888 | |
6889 DW_MUTEX_LOCK; | |
6890 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
6891 { | |
6892 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
6893 if(tmp) | |
6894 handle2 = tmp; | |
6895 } | |
6896 else if(GTK_IS_COMBO(handle)) | |
6897 { | |
6898 handle2 = GTK_COMBO(handle)->list; | |
6899 } | |
6900 if(GTK_IS_LIST(handle2)) | |
6901 { | |
6902 int counter = 0; | |
6903 GList *list = GTK_LIST(handle2)->children; | |
6904 | |
6905 while(list) | |
6906 { | |
6907 if(counter == index) | |
6908 { | |
6909 | |
6910 if(GTK_IS_LIST_ITEM(list->data)) | |
6911 { | |
6912 GtkListItem *li = GTK_LIST_ITEM(list->data); | |
6913 | |
6914 if(GTK_IS_ITEM(&(li->item))) | |
6915 { | |
6916 GtkItem *i = &(li->item); | |
6917 | |
6918 if(GTK_IS_BIN(&(i->bin))) | |
6919 { | |
6920 GtkBin *b = &(i->bin); | |
6921 | |
6922 if(GTK_IS_LABEL(b->child)) | |
6923 gtk_label_set_text(GTK_LABEL(b->child), buffer); | |
6924 } | |
6925 } | |
6926 } | |
6927 else if(GTK_IS_COMBO(handle)) | |
6928 { | |
6929 if(list->data) | |
6930 g_free(list->data); | |
6931 list->data = g_strdup(buffer); | |
6932 } | |
6933 break; | |
6934 } | |
6935 list = list->next; | |
6936 counter++; | |
6937 } | |
6938 } | |
6939 DW_MUTEX_UNLOCK; | |
6940 } | |
6941 | |
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
|
6942 #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
|
6943 /* 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
|
6944 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
|
6945 { |
b479002e013f
Upped the 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 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
|
6947 { |
b479002e013f
Upped the 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 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
|
6949 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
|
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 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
|
6952 } |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
6953 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
|
6954 } |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
6955 #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
|
6956 |
3 | 6957 /* |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6958 * 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
|
6959 * Parameters: |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6960 * 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
|
6961 * 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
|
6962 */ |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6963 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
|
6964 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6965 GtkWidget *handle2 = handle; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6966 int retval = DW_LIT_NONE; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6967 int _locked_by_me = FALSE; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6968 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6969 DW_MUTEX_LOCK; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6970 if(GTK_IS_SCROLLED_WINDOW(handle)) |
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 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
|
6973 if(tmp) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6974 handle2 = tmp; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6975 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6976 if(GTK_IS_LIST(handle2)) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6977 { |
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
|
6978 #if GTK_MAJOR_VERSION > 1 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6979 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
|
6980 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
|
6981 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6982 while(list) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6983 { |
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
|
6984 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
|
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 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
|
6987 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
|
6988 && 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
|
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 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
|
6991 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
|
6992 } |
b479002e013f
Upped the 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 |
b479002e013f
Upped the 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 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
|
6996 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
|
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 #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
|
6999 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
|
7000 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
|
7001 |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7002 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
|
7003 { |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7004 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
|
7005 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7006 retval = counter; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7007 break; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7008 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7009 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7010 list = list->next; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7011 counter++; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7012 } |
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
|
7013 #endif |
60
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 DW_MUTEX_UNLOCK; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7016 return retval; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7017 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7018 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
7019 /* |
3 | 7020 * Returns the index to the item in the list currently selected. |
7021 * Parameters: | |
7022 * handle: Handle to the listbox to be queried. | |
7023 */ | |
7024 unsigned int dw_listbox_selected(HWND handle) | |
7025 { | |
7026 GtkWidget *handle2 = handle; | |
7027 int retval = DW_LIT_NONE; | |
7028 int _locked_by_me = FALSE; | |
7029 | |
7030 DW_MUTEX_LOCK; | |
7031 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
7032 { | |
7033 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
7034 if(tmp) | |
7035 handle2 = tmp; | |
7036 } | |
7037 else if(GTK_IS_COMBO(handle)) | |
7038 { | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7039 retval = (unsigned int)gtk_object_get_data(GTK_OBJECT(handle), "_dw_item"); |
3 | 7040 DW_MUTEX_UNLOCK; |
7041 return retval; | |
7042 } | |
7043 if(GTK_IS_LIST(handle2)) | |
7044 { | |
7045 int counter = 0; | |
7046 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
|
7047 #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
|
7048 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
|
7049 #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
|
7050 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
|
7051 #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
|
7052 if(selection) |
3 | 7053 { |
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
|
7054 while(list) |
3 | 7055 { |
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
|
7056 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
|
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 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
|
7059 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
|
7060 } |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7061 |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
7062 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
|
7063 counter++; |
3 | 7064 } |
7065 } | |
7066 } | |
7067 DW_MUTEX_UNLOCK; | |
7068 return retval; | |
7069 } | |
7070 | |
7071 /* | |
7072 * Sets the selection state of a given index. | |
7073 * Parameters: | |
7074 * handle: Handle to the listbox to be set. | |
7075 * index: Item index. | |
7076 * state: TRUE if selected FALSE if unselected. | |
7077 */ | |
7078 void dw_listbox_select(HWND handle, int index, int state) | |
7079 { | |
7080 GtkWidget *handle2 = handle; | |
7081 int _locked_by_me = FALSE; | |
7082 | |
7083 DW_MUTEX_LOCK; | |
7084 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
7085 { | |
7086 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
7087 if(tmp) | |
7088 handle2 = tmp; | |
7089 } | |
7090 else if(GTK_IS_COMBO(handle)) | |
7091 { | |
7092 handle2 = GTK_COMBO(handle)->list; | |
7093 } | |
7094 if(GTK_IS_LIST(handle2)) | |
7095 { | |
7096 if(state) | |
7097 gtk_list_select_item(GTK_LIST(handle2), index); | |
7098 else | |
7099 gtk_list_unselect_item(GTK_LIST(handle2), index); | |
7100 } | |
7101 DW_MUTEX_UNLOCK; | |
7102 } | |
7103 | |
7104 /* | |
7105 * Deletes the item with given index from the list. | |
7106 * Parameters: | |
7107 * handle: Handle to the listbox to be set. | |
7108 * index: Item index. | |
7109 */ | |
7110 void dw_listbox_delete(HWND handle, int index) | |
7111 { | |
7112 GtkWidget *handle2 = handle; | |
7113 int _locked_by_me = FALSE; | |
7114 | |
7115 DW_MUTEX_LOCK; | |
7116 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
7117 { | |
7118 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
7119 if(tmp) | |
7120 handle2 = tmp; | |
7121 } | |
7122 else if(GTK_IS_COMBO(handle)) | |
7123 { | |
7124 handle2 = GTK_COMBO(handle)->list; | |
7125 } | |
7126 if(GTK_IS_LIST(handle2)) | |
7127 gtk_list_clear_items(GTK_LIST(handle2), index, index); | |
7128 DW_MUTEX_UNLOCK; | |
7129 } | |
7130 | |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7131 /* 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
|
7132 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
|
7133 { |
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
|
7134 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
|
7135 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
|
7136 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
|
7137 |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7138 /* 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
|
7139 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
|
7140 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
|
7141 |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7142 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
|
7143 |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7144 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
|
7145 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
|
7146 |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7147 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
|
7148 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
|
7149 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
|
7150 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
|
7151 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
|
7152 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
|
7153 } |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7154 |
122
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
7155 #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
|
7156 /* 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
|
7157 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
|
7158 { |
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7159 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
|
7160 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
|
7161 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
|
7162 |
145
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7163 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
|
7164 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
|
7165 |
7d2108cbcd3e
Porting DW 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 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
|
7167 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
|
7168 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
|
7169 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
|
7170 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7171 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
|
7172 *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
|
7173 } |
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
|
7174 #endif |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7175 |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7176 /* |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7177 * 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
|
7178 * 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
|
7179 * 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
|
7180 * 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
|
7181 * 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
|
7182 * Returns: |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7183 * 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
|
7184 */ |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7185 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
|
7186 { |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7187 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
|
7188 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
|
7189 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
|
7190 |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7191 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
|
7192 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
|
7193 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
|
7194 else |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7195 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
|
7196 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
|
7197 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
|
7198 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
|
7199 *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
|
7200 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
|
7201 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
|
7202 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
|
7203 #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
|
7204 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
|
7205 #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
|
7206 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
|
7207 #endif |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7208 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
|
7209 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
|
7210 return tmp; |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7211 } |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7212 |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7213 /* |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7214 * 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
|
7215 * Parameters: |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7216 * 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
|
7217 */ |
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
|
7218 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
|
7219 { |
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
|
7220 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
|
7221 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
|
7222 |
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7223 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
|
7224 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
|
7225 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
|
7226 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
|
7227 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7228 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
|
7229 *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
|
7230 |
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7231 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
|
7232 { |
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7233 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
|
7234 |
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7235 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
|
7236 } |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7237 } |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7238 |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7239 /* |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7240 * 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
|
7241 * Parameters: |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7242 * 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
|
7243 */ |
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
|
7244 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
|
7245 { |
7d2108cbcd3e
Porting DW 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 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
|
7247 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7248 if(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
|
7249 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
|
7250 return 0.0; |
3 | 7251 } |
7252 | |
7253 /* | |
7254 * Pack windows (widgets) into a box from the start (or top). | |
7255 * Parameters: | |
7256 * box: Window handle of the box to be packed into. | |
7257 * item: Window handle of the item to be back. | |
7258 * width: Width in pixels of the item or -1 to be self determined. | |
7259 * height: Height in pixels of the item or -1 to be self determined. | |
7260 * hsize: TRUE if the window (widget) should expand horizontally to fill space given. | |
7261 * vsize: TRUE if the window (widget) should expand vertically to fill space given. | |
7262 * pad: Number of pixels of padding around the item. | |
7263 */ | |
7264 void dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) | |
7265 { | |
7266 int _locked_by_me = FALSE; | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
7267 GtkWidget *tmp; |
3 | 7268 |
7269 if(!box) | |
7270 return; | |
7271 | |
7272 DW_MUTEX_LOCK; | |
7273 | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7274 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
|
7275 box = tmp; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
7276 |
3 | 7277 if(!item) |
7278 { | |
7279 item = gtk_label_new(""); | |
7280 gtk_widget_show(item); | |
7281 } | |
7282 | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7283 if(GTK_IS_TABLE(box)) |
3 | 7284 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7285 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
|
7286 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
|
7287 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
|
7288 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7289 /* 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
|
7290 * 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
|
7291 * 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
|
7292 * 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
|
7293 */ |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7294 if(GTK_IS_TABLE(item)) |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7295 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7296 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
|
7297 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7298 if(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 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
|
7301 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
|
7302 item = eventbox; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7303 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7304 } |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7305 |
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
|
7306 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
|
7307 { |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7308 x = 0; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7309 y = boxcount; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7310 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
|
7311 } |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7312 else |
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 x = boxcount; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7315 y = 0; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7316 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
|
7317 } |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7318 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7319 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
|
7320 gtk_object_set_data(GTK_OBJECT(box), "_dw_boxcount", (gpointer)boxcount + 1); |
3 | 7321 gtk_widget_set_usize(item, width, height); |
7322 if(GTK_IS_RADIO_BUTTON(item)) | |
7323 { | |
7324 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
|
7325 GtkWidget *groupstart = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(box), "_dw_group"); |
3 | 7326 |
7327 if(groupstart) | |
7328 { | |
7329 group = gtk_radio_button_group(GTK_RADIO_BUTTON(groupstart)); | |
7330 gtk_radio_button_set_group(GTK_RADIO_BUTTON(item), group); | |
7331 } | |
7332 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
|
7333 gtk_object_set_data(GTK_OBJECT(box), "_dw_group", (gpointer)item); |
3 | 7334 } |
7335 } | |
7336 else | |
7337 { | |
7338 GtkWidget *vbox = gtk_vbox_new(FALSE, 0); | |
7339 | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7340 if(GTK_IS_TABLE(item)) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7341 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7342 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
|
7343 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7344 if(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 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
|
7347 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
|
7348 item = eventbox; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7349 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7350 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7351 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7352 gtk_container_border_width(GTK_CONTAINER(box), pad); |
3 | 7353 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
|
7354 gtk_box_pack_end(GTK_BOX(vbox), item, TRUE, TRUE, 0); |
3 | 7355 gtk_widget_show(vbox); |
7356 | |
7357 gtk_widget_set_usize(item, width, height); | |
7358 gtk_object_set_user_data(GTK_OBJECT(box), vbox); | |
7359 } | |
7360 DW_MUTEX_UNLOCK; | |
7361 } | |
7362 | |
7363 /* | |
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
|
7364 * 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
|
7365 * 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
|
7366 * 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
|
7367 * 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
|
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 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
|
7370 { |
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 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
|
7372 |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
7373 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
|
7374 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
|
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 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
|
7377 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
|
7378 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
|
7379 } |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
7380 |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
7381 /* |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7382 * 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
|
7383 * Parameters: |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7384 * 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
|
7385 * 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
|
7386 */ |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7387 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
|
7388 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7389 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
|
7390 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7391 if(!window) |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7392 return; |
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 DW_MUTEX_LOCK; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7395 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
|
7396 DW_MUTEX_UNLOCK; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7397 } |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7398 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7399 /* |
3 | 7400 * Returns some information about the current operating environment. |
7401 * Parameters: | |
7402 * env: Pointer to a DWEnv struct. | |
7403 */ | |
7404 void dw_environment_query(DWEnv *env) | |
7405 { | |
7406 struct utsname name; | |
7407 char tempbuf[100]; | |
7408 int len, z; | |
7409 | |
7410 uname(&name); | |
7411 strcpy(env->osName, name.sysname); | |
7412 strcpy(tempbuf, name.release); | |
7413 | |
7414 env->MajorBuild = env->MinorBuild = 0; | |
7415 | |
7416 len = strlen(tempbuf); | |
7417 | |
15
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
7418 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
|
7419 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
|
7420 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
|
7421 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
|
7422 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
|
7423 |
3 | 7424 for(z=1;z<len;z++) |
7425 { | |
7426 if(tempbuf[z] == '.') | |
7427 { | |
7428 tempbuf[z] = '\0'; | |
7429 env->MajorVersion = atoi(&tempbuf[z-1]); | |
7430 env->MinorVersion = atoi(&tempbuf[z+1]); | |
7431 return; | |
7432 } | |
7433 } | |
7434 env->MajorVersion = atoi(tempbuf); | |
7435 env->MinorVersion = 0; | |
7436 } | |
7437 | |
7438 /* 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
|
7439 static gint _gtk_file_ok(GtkWidget *widget, DWDialog *dwwait) |
3 | 7440 { |
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 #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
|
7442 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
|
7443 #else |
3 | 7444 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
|
7445 #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
|
7446 char *tmpdup=NULL; |
3 | 7447 |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
7448 if(!dwwait) |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
7449 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
|
7450 |
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 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
|
7452 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
|
7453 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
|
7454 _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
|
7455 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
|
7456 return FALSE; |
3 | 7457 } |
7458 | |
7459 /* 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
|
7460 static gint _gtk_file_cancel(GtkWidget *widget, DWDialog *dwwait) |
3 | 7461 { |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
7462 if(!dwwait) |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
7463 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
|
7464 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
7465 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
|
7466 _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
|
7467 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
|
7468 return FALSE; |
3 | 7469 } |
7470 | |
7471 /* | |
7472 * Opens a file dialog and queries user selection. | |
7473 * Parameters: | |
7474 * title: Title bar text for dialog. | |
7475 * defpath: The default path of the open dialog. | |
7476 * ext: Default file extention. | |
7477 * flags: DW_FILE_OPEN or DW_FILE_SAVE. | |
7478 * Returns: | |
7479 * NULL on error. A malloced buffer containing | |
7480 * the file path on success. | |
7481 * | |
7482 */ | |
7483 char *dw_file_browse(char *title, char *defpath, char *ext, int flags) | |
7484 { | |
7485 GtkWidget *filew; | |
7486 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
|
7487 DWDialog *dwwait; |
3 | 7488 |
7489 DW_MUTEX_LOCK; | |
7490 | |
7491 /* The DW mutex should be sufficient for | |
7492 * insuring no thread changes this unknowingly. | |
7493 */ | |
7494 if(_dw_file_active) | |
7495 { | |
7496 DW_MUTEX_UNLOCK; | |
7497 return NULL; | |
7498 } | |
7499 | |
7500 _dw_file_active = 1; | |
7501 | |
7502 filew = gtk_file_selection_new(title); | |
7503 | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
7504 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
|
7505 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
7506 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
|
7507 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filew)->cancel_button), "clicked", (GtkSignalFunc) _gtk_file_cancel, dwwait); |
3 | 7508 |
7509 if(defpath) | |
7510 gtk_file_selection_set_filename(GTK_FILE_SELECTION(filew), defpath); | |
7511 | |
7512 gtk_widget_show(filew); | |
7513 | |
7514 DW_MUTEX_UNLOCK; | |
7515 | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
7516 return (char *)dw_dialog_wait(dwwait); |
3 | 7517 } |
7518 | |
7519 | |
7520 /* | |
7521 * Execute and external program in a seperate session. | |
7522 * Parameters: | |
7523 * program: Program name with optional path. | |
7524 * type: Either DW_EXEC_CON or DW_EXEC_GUI. | |
7525 * params: An array of pointers to string arguements. | |
7526 * Returns: | |
7527 * -1 on error. | |
7528 */ | |
7529 int dw_exec(char *program, int type, char **params) | |
7530 { | |
7531 int ret = -1; | |
7532 | |
7533 if((ret = fork()) == 0) | |
7534 { | |
7535 int i; | |
7536 | |
7537 for (i = 3; i < 256; i++) | |
7538 close(i); | |
7539 setsid(); | |
7540 if(type == DW_EXEC_GUI) | |
7541 { | |
7542 execvp(program, params); | |
7543 } | |
7544 else if(type == DW_EXEC_CON) | |
7545 { | |
7546 char **tmpargs; | |
7547 | |
7548 if(!params) | |
7549 { | |
7550 tmpargs = malloc(sizeof(char *)); | |
7551 tmpargs[0] = NULL; | |
7552 } | |
7553 else | |
7554 { | |
7555 int z = 0; | |
7556 | |
7557 while(params[z]) | |
7558 { | |
7559 z++; | |
7560 } | |
7561 tmpargs = malloc(sizeof(char *)*(z+3)); | |
7562 z=0; | |
7563 tmpargs[0] = "xterm"; | |
7564 tmpargs[1] = "-e"; | |
7565 while(params[z]) | |
7566 { | |
7567 tmpargs[z+2] = params[z]; | |
7568 z++; | |
7569 } | |
7570 tmpargs[z+2] = NULL; | |
7571 } | |
7572 execvp("xterm", tmpargs); | |
7573 free(tmpargs); | |
7574 } | |
7575 /* If we got here exec failed */ | |
7576 _exit(-1); | |
7577 } | |
7578 return ret; | |
7579 } | |
7580 | |
7581 /* | |
7582 * Loads a web browser pointed at the given URL. | |
7583 * Parameters: | |
7584 * url: Uniform resource locator. | |
7585 */ | |
7586 int dw_browse(char *url) | |
7587 { | |
7588 /* Is there a way to find the webbrowser in Unix? */ | |
7589 char *execargs[3], *browser = "netscape"; | |
7590 | |
7591 execargs[0] = browser; | |
7592 execargs[1] = url; | |
7593 execargs[2] = NULL; | |
7594 | |
7595 return dw_exec(browser, DW_EXEC_GUI, execargs); | |
7596 } | |
7597 | |
7598 /* | |
7599 * Returns a pointer to a static buffer which containes the | |
7600 * current user directory. Or the root directory (C:\ on | |
7601 * OS/2 and Windows). | |
7602 */ | |
7603 char *dw_user_dir(void) | |
7604 { | |
7605 static char _user_dir[1024] = ""; | |
7606 | |
7607 if(!_user_dir[0]) | |
7608 { | |
7609 char *home = getenv("HOME"); | |
7610 | |
7611 if(home) | |
7612 strcpy(_user_dir, home); | |
7613 else | |
7614 strcpy(_user_dir, "/"); | |
7615 } | |
7616 return _user_dir; | |
7617 } | |
7618 | |
7619 /* | |
7620 * Call a function from the window (widget)'s context. | |
7621 * Parameters: | |
7622 * handle: Window handle of the widget. | |
7623 * function: Function pointer to be called. | |
7624 * data: Pointer to the data to be passed to the function. | |
7625 */ | |
7626 void dw_window_function(HWND handle, void *function, void *data) | |
7627 { | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
7628 void (* windowfunc)(void *); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
7629 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
7630 windowfunc = function; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
7631 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
7632 if(windowfunc) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
7633 windowfunc(data); |
3 | 7634 } |
7635 | |
90
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7636 /* |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7637 * 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
|
7638 * Parameters: |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7639 * 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
|
7640 * 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
|
7641 * 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
|
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 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
|
7644 { |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7645 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
|
7646 |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7647 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
|
7648 return; |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7649 |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7650 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
|
7651 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
|
7652 { |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
7653 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
|
7654 { |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
7655 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
|
7656 |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
7657 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
|
7658 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
|
7659 } |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
7660 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
|
7661 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
|
7662 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
|
7663 } |
90
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7664 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
|
7665 } |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7666 |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7667 /* |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7668 * 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
|
7669 * Parameters: |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7670 * 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
|
7671 * 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
|
7672 * 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
|
7673 */ |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7674 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
|
7675 { |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7676 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
|
7677 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
|
7678 |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7679 if(!window) |
92
0a085f295e81
A couple more minor changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
91
diff
changeset
|
7680 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
|
7681 |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7682 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
|
7683 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
|
7684 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
|
7685 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
|
7686 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
|
7687 } |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7688 |
3 | 7689 /* |
195
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7690 * 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
|
7691 * Parameters: |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7692 * 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
|
7693 * 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
|
7694 * 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
|
7695 * Returns: |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7696 * 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
|
7697 */ |
199
b955228477b3
Removed the window parameter to dw_timer_connect() it was no needed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
198
diff
changeset
|
7698 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
|
7699 { |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7700 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
|
7701 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7702 DW_MUTEX_LOCK; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7703 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
|
7704 DW_MUTEX_UNLOCK; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7705 return tag; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7706 } |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7707 |
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 * Removes timer callback. |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7710 * Parameters: |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7711 * 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
|
7712 */ |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7713 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
|
7714 { |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7715 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
|
7716 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7717 DW_MUTEX_LOCK; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7718 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
|
7719 DW_MUTEX_UNLOCK; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7720 } |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7721 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7722 /* |
3 | 7723 * Add a callback to a window event. |
7724 * Parameters: | |
7725 * window: Window handle of signal to be called back. | |
7726 * signame: A string pointer identifying which signal to be hooked. | |
7727 * sigfunc: The pointer to the function to be used as the callback. | |
7728 * data: User data to be passed to the handler function. | |
7729 */ | |
7730 void dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data) | |
7731 { | |
7732 void *thisfunc = _findsigfunc(signame); | |
7733 char *thisname = signame; | |
7734 HWND thiswindow = window; | |
7735 int _locked_by_me = FALSE; | |
7736 | |
7737 DW_MUTEX_LOCK; | |
7738 if(GTK_IS_SCROLLED_WINDOW(thiswindow)) | |
7739 { | |
7740 thiswindow = (HWND)gtk_object_get_user_data(GTK_OBJECT(window)); | |
7741 } | |
7742 | |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7743 if(GTK_IS_MENU_ITEM(thiswindow) && strcmp(signame, DW_SIGNAL_CLICKED) == 0) |
3 | 7744 { |
7745 thisname = "activate"; | |
7746 thisfunc = _findsigfunc(thisname); | |
7747 } | |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7748 else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_CONTEXT) == 0) |
3 | 7749 { |
7750 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
|
7751 thisfunc = _findsigfunc(DW_SIGNAL_ITEM_CONTEXT); |
3 | 7752 } |
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
|
7753 #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
|
7754 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
|
7755 { |
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
|
7756 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
|
7757 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
7758 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
|
7759 (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
|
7760 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
|
7761 (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
|
7762 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
|
7763 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
|
7764 } |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7765 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
|
7766 { |
362
eb61b854fd58
Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
361
diff
changeset
|
7767 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
|
7768 |
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
|
7769 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
|
7770 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
|
7771 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
7772 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
|
7773 (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
|
7774 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
|
7775 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
|
7776 } |
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
|
7777 #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
|
7778 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
|
7779 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
7780 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
|
7781 |
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
|
7782 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
|
7783 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7784 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
|
7785 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
|
7786 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
|
7787 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
|
7788 (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
|
7789 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
|
7790 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
|
7791 } |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7792 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
|
7793 { |
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
|
7794 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
|
7795 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7796 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
|
7797 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
|
7798 (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
|
7799 } |
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
|
7800 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
|
7801 } |
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
|
7802 #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
|
7803 else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_ENTER) == 0) |
3 | 7804 { |
364
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
7805 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
|
7806 (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
|
7807 |
3 | 7808 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
|
7809 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
|
7810 } |
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7811 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
|
7812 { |
d35771f70bdd
Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
163
diff
changeset
|
7813 thisname = "select_row"; |
d35771f70bdd
Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
163
diff
changeset
|
7814 thisfunc = (void *)_container_select_row; |
d35771f70bdd
Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
163
diff
changeset
|
7815 } |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7816 else if(GTK_IS_COMBO(thiswindow) && strcmp(signame, DW_SIGNAL_LIST_SELECT) == 0) |
3 | 7817 { |
7818 thisname = "select_child"; | |
7819 thiswindow = GTK_COMBO(thiswindow)->list; | |
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(GTK_IS_LIST(thiswindow) && strcmp(signame, DW_SIGNAL_LIST_SELECT) == 0) |
3 | 7822 { |
7823 thisname = "select_child"; | |
7824 } | |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7825 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
|
7826 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
7827 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
|
7828 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
|
7829 thiswindow = GTK_COMBO(thiswindow)->entry; |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
7830 } |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7831 #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
|
7832 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
|
7833 { |
b6948eac375a
Sync with the latest dynamic windows, tree fixes, and other miscellaneous
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
54
diff
changeset
|
7834 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
|
7835 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
|
7836 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
|
7837 } |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7838 #endif |
205
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
7839 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
|
7840 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
|
7841 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7842 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
|
7843 } |
331
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
7844 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
|
7845 { |
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
7846 thisname = "switch-page"; |
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
7847 } |
3 | 7848 |
7849 if(!thisfunc || !thiswindow) | |
7850 { | |
7851 DW_MUTEX_UNLOCK; | |
7852 return; | |
7853 } | |
7854 | |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
7855 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
|
7856 (gpointer)_set_signal_handler(thiswindow, window, sigfunc, data)); |
3 | 7857 DW_MUTEX_UNLOCK; |
7858 } | |
7859 | |
7860 /* | |
7861 * Removes callbacks for a given window with given name. | |
7862 * Parameters: | |
7863 * window: Window handle of callback to be removed. | |
7864 */ | |
7865 void dw_signal_disconnect_by_name(HWND window, char *signame) | |
7866 { | |
7867 #if 0 | |
7868 gtk_signal_disconnect_by_name(window, signame); | |
7869 #endif | |
7870 } | |
7871 | |
7872 /* | |
7873 * Removes all callbacks for a given window. | |
7874 * Parameters: | |
7875 * window: Window handle of callback to be removed. | |
7876 */ | |
7877 void dw_signal_disconnect_by_window(HWND window) | |
7878 { | |
7879 #if 0 | |
7880 gtk_signal_disconnect_by_window(window); | |
7881 #endif | |
7882 } | |
7883 | |
7884 /* | |
7885 * Removes all callbacks for a given window with specified data. | |
7886 * Parameters: | |
7887 * window: Window handle of callback to be removed. | |
7888 * data: Pointer to the data to be compared against. | |
7889 */ | |
7890 void dw_signal_disconnect_by_data(HWND window, void *data) | |
7891 { | |
7892 dw_signal_disconnect_by_data(window, data); | |
7893 } | |
153
a371875d5486
Sync up with the latest F/X sources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
151
diff
changeset
|
7894 |