Mercurial > dwindows
annotate gtk/dw.c @ 373:d04b0699fc28
Fixes for background color drawing on GTK 2.x.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 27 Apr 2003 19:53:29 +0000 |
parents | 3ef2cf70ee07 |
children | 47dc310e6d74 |
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 | |
28 /* These are used for resource management */ | |
29 #if defined(DW_RESOURCES) && !defined(BUILD_DLL) | |
30 extern DWResources _resources; | |
31 #endif | |
32 | |
33 GdkColor _colors[] = | |
34 { | |
35 { 0, 0x0000, 0x0000, 0x0000 }, /* 0 black */ | |
36 { 0, 0xbbbb, 0x0000, 0x0000 }, /* 1 red */ | |
37 { 0, 0x0000, 0xbbbb, 0x0000 }, /* 2 green */ | |
38 { 0, 0xaaaa, 0xaaaa, 0x0000 }, /* 3 yellow */ | |
39 { 0, 0x0000, 0x0000, 0xcccc }, /* 4 blue */ | |
40 { 0, 0xbbbb, 0x0000, 0xbbbb }, /* 5 magenta */ | |
41 { 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
|
42 { 0, 0xbbbb, 0xbbbb, 0xbbbb }, /* 7 white */ |
3 | 43 { 0, 0x7777, 0x7777, 0x7777 }, /* 8 grey */ |
44 { 0, 0xffff, 0x0000, 0x0000 }, /* 9 bright red */ | |
45 { 0, 0x0000, 0xffff, 0x0000 }, /* 10 bright green */ | |
46 { 0, 0xeeee, 0xeeee, 0x0000 }, /* 11 bright yellow */ | |
47 { 0, 0x0000, 0x0000, 0xffff }, /* 12 bright blue */ | |
48 { 0, 0xffff, 0x0000, 0xffff }, /* 13 bright magenta */ | |
49 { 0, 0x0000, 0xeeee, 0xeeee }, /* 14 bright cyan */ | |
50 { 0, 0xffff, 0xffff, 0xffff }, /* 15 bright white */ | |
51 }; | |
52 | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
53 #define DW_THREAD_LIMIT 50 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
54 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
55 DWTID _dw_thread_list[DW_THREAD_LIMIT]; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
56 GdkColor _foreground[DW_THREAD_LIMIT]; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
57 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
|
58 int _transparent[DW_THREAD_LIMIT]; |
3 | 59 |
93
98cce029a611
Changed handling of menu item click events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
92
diff
changeset
|
60 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
|
61 |
359
9ddcbbaebd50
Fix warning caused by removal of obsolete code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
358
diff
changeset
|
62 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
|
63 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
|
64 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
|
65 /* 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
|
66 static int _dw_border_width = 12, _dw_border_height = 28; |
3 | 67 |
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
|
68 #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
|
69 #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 | 70 |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
71 #define DEFAULT_SIZE_WIDTH 12 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
72 #define DEFAULT_SIZE_HEIGHT 6 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
73 #define DEFAULT_TITLEBAR_HEIGHT 22 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
74 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
75 static GdkColormap *_dw_cmap = NULL; |
3 | 76 |
77 /* 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
|
78 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
|
79 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
|
80 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
|
81 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
|
82 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
|
83 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
|
84 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
|
85 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
|
86 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
|
87 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
|
88 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
|
89 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
|
90 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
|
91 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
|
92 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
|
93 #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
|
94 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
|
95 #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
|
96 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
|
97 #endif |
331
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
98 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
|
99 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
100 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
|
101 { |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
102 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
|
103 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
|
104 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
|
105 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
|
106 #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
|
107 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
|
108 #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
|
109 } DWPrivatePixmap; |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
110 |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
111 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
|
112 static int _PixmapCount = 0; |
3 | 113 |
114 typedef struct | |
115 { | |
116 void *func; | |
117 char name[30]; | |
118 | |
119 } SignalList; | |
120 | |
121 typedef struct | |
122 { | |
123 HWND window; | |
124 void *func; | |
125 gpointer data; | |
126 | |
127 } SignalHandler; | |
128 | |
331
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
129 #define SIGNALMAX 17 |
3 | 130 |
131 /* 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
|
132 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
|
133 { _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
|
134 { _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
|
135 { _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
|
136 { _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
|
137 { _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
|
138 { _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
|
139 { _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
|
140 { _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
|
141 { _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
|
142 { _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
|
143 { _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
|
144 { _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
|
145 { _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
|
146 { _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
|
147 { _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
|
148 { _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
|
149 { _switch_page_event, DW_SIGNAL_SWITCH_PAGE } |
3 | 150 }; |
151 | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
152 /* Alignment flags */ |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
153 #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
|
154 #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
|
155 #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
|
156 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
157 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
|
158 { |
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
159 #ifdef __sun__ |
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
160 /* 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
|
161 struct timespec req; |
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
162 |
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
163 req.tv_sec = 0; |
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
164 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
|
165 |
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
166 nanosleep(&req, NULL); |
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
167 #else |
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
168 usleep(period * 1000); |
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
169 #endif |
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 |
3 | 172 /* 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
|
173 static void *_findsigfunc(char *signame) |
3 | 174 { |
175 int z; | |
176 | |
177 for(z=0;z<SIGNALMAX;z++) | |
178 { | |
179 if(strcasecmp(signame, SignalTranslate[z].name) == 0) | |
180 return SignalTranslate[z].func; | |
181 } | |
182 return NULL; | |
183 } | |
184 | |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
185 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
|
186 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
187 int counter = (int)data; |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
188 SignalHandler sh; |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
189 char text[100]; |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
190 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
191 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
|
192 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
|
193 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
|
194 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
|
195 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
|
196 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
|
197 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
198 return sh; |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
199 } |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
200 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
201 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
|
202 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
203 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
|
204 char text[100]; |
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 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
|
207 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
|
208 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
|
209 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
|
210 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
|
211 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
|
212 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
213 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), "_dw_sigcounter", (gpointer)counter); |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
215 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
216 return counter - 1; |
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 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
219 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
|
220 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
221 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
|
222 int retval = FALSE; |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
223 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
224 if(work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
225 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
226 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
|
227 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
228 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
|
229 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
230 return retval; |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
231 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
232 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
233 static gint _button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data) |
3 | 234 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
235 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
|
236 int retval = FALSE; |
3 | 237 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
238 if(work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
239 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
240 int (*buttonfunc)(HWND, int, int, int, void *) = work.func; |
3 | 241 int mybutton = event->button; |
242 | |
243 if(event->button == 3) | |
244 mybutton = 2; | |
245 else if(event->button == 2) | |
246 mybutton = 3; | |
247 | |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
248 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
|
249 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
250 return retval; |
3 | 251 } |
252 | |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
253 static gint _button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer data) |
3 | 254 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
255 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
|
256 int retval = FALSE; |
3 | 257 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
258 if(work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
259 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
260 int (*buttonfunc)(HWND, int, int, int, void *) = work.func; |
3 | 261 int mybutton = event->button; |
262 | |
263 if(event->button == 3) | |
264 mybutton = 2; | |
265 else if(event->button == 2) | |
266 mybutton = 3; | |
267 | |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
268 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
|
269 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
270 return retval; |
3 | 271 } |
272 | |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
273 static gint _motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gpointer data) |
3 | 274 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
275 SignalHandler work = _get_signal_handler(widget, data); |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
276 int retval = FALSE; |
3 | 277 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
278 if(work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
279 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
280 int (*motionfunc)(HWND, int, int, int, void *) = work.func; |
3 | 281 int keys = 0, x, y; |
282 GdkModifierType state; | |
283 | |
284 if (event->is_hint) | |
285 gdk_window_get_pointer (event->window, &x, &y, &state); | |
286 else | |
287 { | |
288 x = event->x; | |
289 y = event->y; | |
290 state = event->state; | |
291 } | |
292 | |
293 if (state & GDK_BUTTON1_MASK) | |
294 keys = DW_BUTTON1_MASK; | |
295 if (state & GDK_BUTTON3_MASK) | |
296 keys |= DW_BUTTON2_MASK; | |
297 if (state & GDK_BUTTON2_MASK) | |
298 keys |= DW_BUTTON3_MASK; | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
299 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
300 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
|
301 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
302 return retval; |
3 | 303 } |
304 | |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
305 static gint _delete_event(GtkWidget *widget, GdkEvent *event, gpointer data) |
3 | 306 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
307 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
|
308 int retval = FALSE; |
3 | 309 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
310 if(work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
311 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
312 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
|
313 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
314 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
|
315 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
316 return retval; |
3 | 317 } |
318 | |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
319 static gint _key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data) |
3 | 320 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
321 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
|
322 int retval = FALSE; |
3 | 323 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
324 if(work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
325 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
326 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
|
327 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
328 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
|
329 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
|
330 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
331 return retval; |
3 | 332 } |
333 | |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
334 static gint _generic_event(GtkWidget *widget, gpointer data) |
3 | 335 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
336 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
|
337 int retval = FALSE; |
3 | 338 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
339 if(work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
340 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
341 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
|
342 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
343 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
|
344 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
345 return retval; |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
346 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
347 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
348 static gint _activate_event(GtkWidget *widget, gpointer data) |
3 | 349 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
350 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
|
351 int retval = FALSE; |
3 | 352 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
353 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
|
354 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
355 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
|
356 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
357 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
|
358 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
359 return retval; |
3 | 360 } |
361 | |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
362 static gint _configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data) |
3 | 363 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
364 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
|
365 int retval = FALSE; |
3 | 366 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
367 if(work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
368 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
369 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
|
370 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
371 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
|
372 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
373 return retval; |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
374 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
375 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
376 static gint _expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data) |
3 | 377 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
378 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
|
379 int retval = FALSE; |
3 | 380 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
381 if(work.window) |
3 | 382 { |
383 DWExpose exp; | |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
384 int (*exposefunc)(HWND, DWExpose *, void *) = work.func; |
3 | 385 |
386 exp.x = event->area.x; | |
387 exp.y = event->area.y; | |
388 exp.width = event->area.width; | |
389 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
|
390 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
|
391 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
392 return retval; |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
393 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
394 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
395 static gint _item_select_event(GtkWidget *widget, GtkWidget *child, gpointer data) |
3 | 396 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
397 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
|
398 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
|
399 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
|
400 |
3aa9ef0b3996
Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
37
diff
changeset
|
401 if(_dw_recursing) |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
402 return FALSE; |
3 | 403 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
404 if(work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
405 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
406 int (*selectfunc)(HWND, int, void *) = work.func; |
3 | 407 GList *list; |
408 int item = 0; | |
409 | |
39
3aa9ef0b3996
Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
37
diff
changeset
|
410 _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
|
411 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
412 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
|
413 list = GTK_LIST(GTK_COMBO(work.window)->list)->children; |
3 | 414 else if(GTK_IS_LIST(widget)) |
415 list = GTK_LIST(widget)->children; | |
416 else | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
417 return FALSE; |
3 | 418 |
419 while(list) | |
420 { | |
421 if(list->data == (gpointer)child) | |
422 { | |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
423 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
|
424 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
425 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
|
426 if(selectfunc) |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
427 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
|
428 } |
3 | 429 break; |
430 } | |
431 item++; | |
432 list = list->next; | |
433 } | |
39
3aa9ef0b3996
Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
37
diff
changeset
|
434 _dw_recursing = 0; |
3 | 435 } |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
436 return retval; |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
437 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
438 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
439 static gint _container_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data) |
3 | 440 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
441 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
|
442 int retval = FALSE; |
3 | 443 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
444 if(work.window) |
3 | 445 { |
446 if(event->button == 3) | |
447 { | |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
448 int (*contextfunc)(HWND, char *, int, int, void *, void *) = work.func; |
3 | 449 char *text; |
450 int row, col; | |
451 | |
452 gtk_clist_get_selection_info(GTK_CLIST(widget), event->x, event->y, &row, &col); | |
453 | |
454 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
|
455 retval = contextfunc(work.window, text, event->x, event->y, work.data, NULL); |
3 | 456 } |
457 } | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
458 return retval; |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
459 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
460 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
461 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
|
462 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
463 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
|
464 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
|
465 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
466 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
|
467 { |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
468 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
|
469 { |
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
|
470 #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
|
471 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
|
472 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
|
473 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
|
474 |
e0e73b4372a6
GTK 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(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
|
476 { |
e0e73b4372a6
GTK 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 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
|
478 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
|
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(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
|
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 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
|
483 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
|
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 } |
e0e73b4372a6
GTK 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 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
487 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
|
488 #else |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
489 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
|
490 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
|
491 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
|
492 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
493 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
|
494 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
495 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
|
496 |
c4e1139d9872
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 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
|
498 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
499 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
|
500 |
c4e1139d9872
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 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
|
502 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
503 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
|
504 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
|
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 } |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
507 } |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
508 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
509 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
|
510 #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
|
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 } |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
513 return retval; |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
514 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
515 |
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
|
516 #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
|
517 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
|
518 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
519 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
|
520 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
|
521 |
362
eb61b854fd58
Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
361
diff
changeset
|
522 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
|
523 { |
eb61b854fd58
Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
361
diff
changeset
|
524 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
|
525 |
eb61b854fd58
Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
361
diff
changeset
|
526 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
|
527 { |
362
eb61b854fd58
Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
361
diff
changeset
|
528 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
|
529 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
|
530 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
|
531 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
|
532 |
eb61b854fd58
Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
361
diff
changeset
|
533 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
|
534 { |
eb61b854fd58
Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
361
diff
changeset
|
535 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
|
536 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
|
537 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
|
538 } |
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
|
539 } |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
540 } |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
541 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
|
542 } |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
543 #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
|
544 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
|
545 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
546 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
|
547 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
|
548 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
|
549 |
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
|
550 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
|
551 { |
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 *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
|
553 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
|
554 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
|
555 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
|
556 } |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
557 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
558 if(work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
559 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
560 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
|
561 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
|
562 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
|
563 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
|
564 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
565 return retval; |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
566 } |
140
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
567 #endif |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
568 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
569 static gint _container_select_event(GtkWidget *widget, GdkEventButton *event, gpointer data) |
3 | 570 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
571 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
|
572 int retval = FALSE; |
3 | 573 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
574 if(work.window) |
3 | 575 { |
576 if(event->button == 1 && event->type == GDK_2BUTTON_PRESS) | |
577 { | |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
578 int (*contextfunc)(HWND, char *, void *) = work.func; |
3 | 579 char *text; |
580 int row, col; | |
581 | |
582 gtk_clist_get_selection_info(GTK_CLIST(widget), event->x, event->y, &row, &col); | |
583 | |
584 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
|
585 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
|
586 gtk_object_set_data(GTK_OBJECT(widget), "_dw_double_click", (gpointer)1); |
3 | 587 } |
588 } | |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
589 return retval; |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
590 } |
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
591 |
364
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
592 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
|
593 { |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
594 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
|
595 int retval = FALSE; |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
596 |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
597 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
|
598 { |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
599 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
|
600 char *text; |
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 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
|
603 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
|
604 } |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
605 return retval; |
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 |
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
|
608 /* 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
|
609 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
|
610 { |
599644ca9064
Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
340
diff
changeset
|
611 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
|
612 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
|
613 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
|
614 |
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 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
|
616 { |
599644ca9064
Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
340
diff
changeset
|
617 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
|
618 { |
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 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
|
620 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
|
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 } |
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 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
|
624 } |
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 |
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 |
331
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
627 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
|
628 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
629 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
|
630 int retval = FALSE; |
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
631 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
632 if(work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
633 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
634 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
|
635 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
|
636 } |
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
637 return retval; |
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
638 } |
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
639 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
640 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
|
641 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
642 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
|
643 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
|
644 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
|
645 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
646 if(!work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
647 return TRUE; |
311
24c1dfffe97e
Unified the callback functions for tree and container widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
310
diff
changeset
|
648 |
320
ae5b1eecea12
Don't send a DW_SIGNAL_ITEM_SELECT after DW_SIGNAL_ENTER.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
319
diff
changeset
|
649 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
|
650 { |
ae5b1eecea12
Don't send a DW_SIGNAL_ITEM_SELECT after DW_SIGNAL_ENTER.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
319
diff
changeset
|
651 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
|
652 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
|
653 } |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
654 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
|
655 } |
d35771f70bdd
Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
163
diff
changeset
|
656 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
657 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
|
658 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
659 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
|
660 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
661 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
|
662 newval++; |
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 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
|
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 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
667 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
|
668 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
669 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
|
670 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
|
671 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
|
672 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
|
673 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
674 if(slider) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
675 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
676 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
|
677 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
678 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
|
679 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
680 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
|
681 |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
682 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
|
683 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
|
684 else |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
685 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
|
686 } |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
687 } |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
688 else if(scrollbar) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
689 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
690 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
|
691 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
692 if(work.window) |
208
5349a0735fda
Hopefully fixed value_changed signal handler on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
205
diff
changeset
|
693 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
694 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
|
695 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
696 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
|
697 } |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
698 } |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
699 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
|
700 } |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
701 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
702 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
|
703 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
704 GtkWidget *next = (GtkWidget *)data; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
705 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
706 if(next) |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
707 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
708 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
|
709 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
710 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
|
711 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
|
712 else |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
713 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
|
714 } |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
715 } |
131
594307469c79
Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
130
diff
changeset
|
716 return FALSE; |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
717 } |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
718 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
719 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
|
720 { |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
721 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
|
722 { |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
723 *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
|
724 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
|
725 *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
|
726 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
|
727 *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
|
728 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
|
729 } |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
730 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
|
731 } |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
732 |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
733 static GdkPixmap *_find_pixmap(GdkBitmap **bitmap, long id, HWND handle, unsigned long *userwidth, unsigned long *userheight) |
3 | 734 { |
735 char *data = NULL; | |
736 int z; | |
737 | |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
738 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
|
739 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
|
740 |
3 | 741 for(z=0;z<_resources.resource_max;z++) |
742 { | |
743 if(_resources.resource_id[z] == id) | |
744 { | |
745 data = _resources.resource_data[z]; | |
746 break; | |
747 } | |
748 } | |
749 | |
750 if(data) | |
751 { | |
752 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
|
753 #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
|
754 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
|
755 |
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
756 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
|
757 *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
|
758 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
|
759 *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
|
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 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
|
762 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
|
763 #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
|
764 gdk_imlib_data_to_pixmap((char **)data, &icon_pixmap, bitmap); |
3 | 765 #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
|
766 icon_pixmap = gdk_pixmap_create_from_xpm_d(handle->window, bitmap, &_colors[DW_CLR_PALEGRAY], (char **)data); |
3 | 767 #endif |
768 return icon_pixmap; | |
769 } | |
770 return NULL; | |
771 } | |
772 | |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
773 #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
|
774 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
|
775 { |
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
|
776 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
|
777 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
|
778 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
|
779 } |
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 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
781 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
|
782 { |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
783 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
|
784 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
|
785 |
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
|
786 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
|
787 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
|
788 |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
789 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
|
790 { |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
791 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
|
792 { |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
793 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
|
794 break; |
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 } |
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 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
|
799 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
|
800 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
|
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 #endif |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
803 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
804 static void _size_allocate(GtkWindow *window) |
3 | 805 { |
806 XSizeHints sizehints; | |
807 | |
808 sizehints.base_width = 1; | |
809 sizehints.base_height = 1; | |
810 sizehints.width_inc = 1; | |
811 sizehints.height_inc = 1; | |
812 sizehints.min_width = 8; | |
813 sizehints.min_height = 8; | |
814 | |
815 sizehints.flags = (PBaseSize|PMinSize|PResizeInc); | |
816 | |
817 XSetWMNormalHints (GDK_DISPLAY(), | |
818 GDK_WINDOW_XWINDOW (GTK_WIDGET (window)->window), | |
819 &sizehints); | |
820 gdk_flush (); | |
821 } | |
822 | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
823 /* 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
|
824 static int _find_thread_index(DWTID tid) |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
825 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
826 int z; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
827 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
828 for(z=0;z<DW_THREAD_LIMIT;z++) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
829 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
830 if(_dw_thread_list[z] == tid) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
831 return 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 return 0; |
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 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
836 /* 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
|
837 static void _dw_thread_add(DWTID tid) |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
838 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
839 int z; |
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 for(z=0;z<DW_THREAD_LIMIT;z++) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
842 { |
264
20becf7df38a
Prevent duplicate thread IDs from getting added to the thread list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
259
diff
changeset
|
843 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
|
844 return; |
20becf7df38a
Prevent duplicate thread IDs from getting added to the thread list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
259
diff
changeset
|
845 |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
846 if(_dw_thread_list[z] == (DWTID)-1) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
847 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
848 _dw_thread_list[z] = tid; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
849 _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
|
850 _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
|
851 _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
|
852 _transparent[z] = 1; |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
853 return; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
854 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
855 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
856 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
857 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
858 /* 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
|
859 static void _dw_thread_remove(DWTID tid) |
48
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 int z; |
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 for(z=0;z<DW_THREAD_LIMIT;z++) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
864 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
865 if(_dw_thread_list[z] == (DWTID)tid) |
51
d97de82f0b6e
Fix warning on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
49
diff
changeset
|
866 _dw_thread_list[z] = (DWTID)-1; |
48
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 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
869 |
3 | 870 /* |
871 * Initializes the Dynamic Windows engine. | |
872 * Parameters: | |
873 * newthread: True if this is the only thread. | |
874 * False if there is already a message loop running. | |
875 */ | |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
876 int dw_int_init(DWResources *res, int newthread, int *argc, char **argv[]) |
3 | 877 { |
878 int z; | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
879 char *tmp; |
3 | 880 |
881 if(res) | |
882 { | |
883 _resources.resource_max = res->resource_max; | |
884 _resources.resource_id = res->resource_id; | |
885 _resources.resource_data = res->resource_data; | |
886 } | |
887 gtk_set_locale(); | |
888 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
|
889 #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
|
890 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
|
891 #endif |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
892 |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
893 gtk_init(argc, argv); |
3 | 894 #ifdef USE_IMLIB |
895 gdk_imlib_init(); | |
896 #endif | |
897 /* Add colors to the system colormap */ | |
898 _dw_cmap = gdk_colormap_get_system(); | |
899 for(z=0;z<16;z++) | |
900 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
|
901 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
902 tmp = getenv("DW_BORDER_WIDTH"); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
903 if(tmp) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
904 _dw_border_width = atoi(tmp); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
905 tmp = getenv("DW_BORDER_HEIGHT"); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
906 if(tmp) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
907 _dw_border_height = atoi(tmp); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
908 |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
909 for(z=0;z<DW_THREAD_LIMIT;z++) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
910 _dw_thread_list[z] = (DWTID)-1; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
911 |
77
002da4d18ac6
Set tooltip background color to yellow.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
76
diff
changeset
|
912 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
|
913 |
3 | 914 return TRUE; |
915 } | |
916 | |
917 /* | |
918 * 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
|
919 */ |
2a0d7b57a6da
Removed unnecessary parameters from dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
149
diff
changeset
|
920 void dw_main(void) |
3 | 921 { |
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
|
922 gdk_threads_enter(); |
3 | 923 _dw_thread = pthread_self(); |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
924 _dw_thread_add(_dw_thread); |
3 | 925 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
|
926 _dw_thread = (pthread_t)-1; |
3 | 927 gdk_threads_leave(); |
928 } | |
929 | |
930 /* | |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
931 * 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
|
932 * 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
|
933 * 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
|
934 */ |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
935 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
|
936 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
937 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
|
938 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
|
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 gettimeofday(&start, NULL); |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
941 |
340
eff674cb4935
Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
338
diff
changeset
|
942 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
|
943 { |
eff674cb4935
Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
338
diff
changeset
|
944 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
|
945 |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
946 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
|
947 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
948 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
|
949 { |
340
eff674cb4935
Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
338
diff
changeset
|
950 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
|
951 { |
eff674cb4935
Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
338
diff
changeset
|
952 gdk_threads_enter(); |
eff674cb4935
Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
338
diff
changeset
|
953 _dw_thread = curr; |
eff674cb4935
Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
338
diff
changeset
|
954 } |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
955 if(gtk_events_pending()) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
956 gtk_main_iteration(); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
957 else |
237
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
958 _dw_msleep(1); |
340
eff674cb4935
Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
338
diff
changeset
|
959 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
|
960 { |
eff674cb4935
Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
338
diff
changeset
|
961 _dw_thread = orig; |
eff674cb4935
Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
338
diff
changeset
|
962 gdk_threads_leave(); |
eff674cb4935
Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
338
diff
changeset
|
963 } |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
964 gettimeofday(&tv, NULL); |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
965 } |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
966 } |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
967 else |
237
efa724294b5f
Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
233
diff
changeset
|
968 _dw_msleep(milliseconds); |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
969 } |
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 /* |
205
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
972 * 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
|
973 */ |
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
974 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
|
975 { |
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
|
976 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
|
977 _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
|
978 _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
|
979 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
|
980 _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
|
981 gdk_threads_leave(); |
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
982 } |
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
983 |
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
984 /* |
3 | 985 * Free's memory allocated by dynamic windows. |
986 * Parameters: | |
987 * ptr: Pointer to dynamic windows allocated | |
988 * memory to be free()'d. | |
989 */ | |
990 void dw_free(void *ptr) | |
991 { | |
992 free(ptr); | |
993 } | |
994 | |
995 /* | |
996 * Allocates and initializes a dialog struct. | |
997 * Parameters: | |
998 * data: User defined data to be passed to functions. | |
999 */ | |
1000 DWDialog *dw_dialog_new(void *data) | |
1001 { | |
1002 DWDialog *tmp = malloc(sizeof(DWDialog)); | |
1003 | |
1004 tmp->eve = dw_event_new(); | |
1005 dw_event_reset(tmp->eve); | |
1006 tmp->data = data; | |
1007 tmp->done = FALSE; | |
1008 tmp->result = NULL; | |
1009 | |
1010 return tmp; | |
1011 } | |
1012 | |
1013 /* | |
1014 * Accepts a dialog struct and returns the given data to the | |
1015 * initial called of dw_dialog_wait(). | |
1016 * Parameters: | |
1017 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). | |
1018 * result: Data to be returned by dw_dialog_wait(). | |
1019 */ | |
1020 int dw_dialog_dismiss(DWDialog *dialog, void *result) | |
1021 { | |
1022 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
|
1023 if(pthread_self() == _dw_thread || _dw_thread == (pthread_t)-1) |
3 | 1024 gtk_main_quit(); |
1025 else | |
1026 dw_event_post(dialog->eve); | |
1027 dialog->done = TRUE; | |
1028 return 0; | |
1029 } | |
1030 | |
1031 /* | |
1032 * Accepts a dialog struct waits for dw_dialog_dismiss() to be | |
1033 * called by a signal handler with the given dialog struct. | |
1034 * Parameters: | |
1035 * dialog: Pointer to a dialog struct aquired by dw_dialog_new). | |
1036 */ | |
1037 void *dw_dialog_wait(DWDialog *dialog) | |
1038 { | |
1039 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
|
1040 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
|
1041 |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
1042 /* _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
|
1043 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
|
1044 { |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
1045 _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
|
1046 newprocess = 1; |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
1047 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
|
1048 } |
3 | 1049 |
1050 if(pthread_self() == _dw_thread) | |
1051 gtk_main(); | |
1052 else | |
1053 dw_event_wait(dialog->eve, -1); | |
1054 | |
41
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
1055 if(newprocess) |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
1056 { |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
1057 _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
|
1058 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
|
1059 } |
af0a78aa0d45
More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
40
diff
changeset
|
1060 |
3 | 1061 dw_event_close(&dialog->eve); |
1062 tmp = dialog->result; | |
1063 free(dialog); | |
1064 return tmp; | |
1065 } | |
1066 | |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
1067 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
|
1068 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1069 DWDialog *dwwait = (DWDialog *)data; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1070 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1071 if(!dwwait) |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
1072 return FALSE; |
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 dw_window_destroy((HWND)dwwait->data); |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1075 dw_dialog_dismiss((DWDialog *)data, (void *)0); |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
1076 return FALSE; |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1077 } |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1078 |
3 | 1079 /* |
1080 * Displays a Message Box with given text and title.. | |
1081 * Parameters: | |
1082 * title: The title of the message box. | |
1083 * format: printf style format string. | |
1084 * ...: Additional variables for use in the format. | |
1085 */ | |
1086 int dw_messagebox(char *title, char *format, ...) | |
1087 { | |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1088 HWND entrywindow, mainbox, okbutton, buttonbox, stext; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1089 ULONG flStyle = DW_FCF_TITLEBAR | DW_FCF_SHELLPOSITION | DW_FCF_DLGBORDER; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1090 DWDialog *dwwait; |
3 | 1091 va_list args; |
1092 char outbuf[256]; | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1093 int x, y; |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1094 |
3 | 1095 va_start(args, format); |
1096 vsprintf(outbuf, format, args); | |
1097 va_end(args); | |
1098 | |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1099 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
|
1100 mainbox = dw_box_new(DW_VERT, 10); |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1101 dw_box_pack_start(entrywindow, mainbox, 0, 0, TRUE, TRUE, 0); |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1102 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1103 /* Archive Name */ |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1104 stext = dw_text_new(outbuf, 0); |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1105 dw_window_set_style(stext, DW_DT_WORDBREAK, DW_DT_WORDBREAK); |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1106 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1107 dw_box_pack_start(mainbox, stext, 205, 50, TRUE, TRUE, 2); |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1108 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1109 /* 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
|
1110 buttonbox = dw_box_new(DW_HORZ, 10); |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1111 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1112 dw_box_pack_start(mainbox, buttonbox, 0, 0, TRUE, FALSE, 0); |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1113 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1114 okbutton = dw_button_new("Ok", 1001L); |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1115 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1116 dw_box_pack_start(buttonbox, okbutton, 50, 30, TRUE, FALSE, 2); |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1117 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1118 dwwait = dw_dialog_new((void *)entrywindow); |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1119 |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
1120 dw_signal_connect(okbutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_ok_func), (void *)dwwait); |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1121 |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1122 x = (dw_screen_width() - 220)/2; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1123 y = (dw_screen_height() - 110)/2; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1124 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1125 dw_window_set_pos_size(entrywindow, x, y, 220, 110); |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1126 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1127 dw_window_show(entrywindow); |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1128 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1129 dw_dialog_wait(dwwait); |
3 | 1130 |
1131 return strlen(outbuf); | |
1132 } | |
1133 | |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
1134 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
|
1135 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1136 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
|
1137 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1138 if(!dwwait) |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
1139 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
|
1140 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1141 dw_window_destroy((HWND)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
|
1142 dw_dialog_dismiss((DWDialog *)data, (void *)1); |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
1143 return FALSE; |
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
1144 } |
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
1145 |
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
1146 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
|
1147 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1148 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
|
1149 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1150 if(!dwwait) |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
1151 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
|
1152 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1153 dw_window_destroy((HWND)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
|
1154 dw_dialog_dismiss((DWDialog *)data, (void *)0); |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
1155 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
|
1156 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1157 |
3 | 1158 /* |
1159 * Displays a Message Box with given text and title.. | |
1160 * Parameters: | |
1161 * title: The title of the message box. | |
1162 * text: The text to display in the box. | |
1163 * Returns: | |
1164 * True if YES False of NO. | |
1165 */ | |
1166 int dw_yesno(char *title, char *text) | |
1167 { | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1168 HWND entrywindow, mainbox, nobutton, yesbutton, buttonbox, stext; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1169 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
|
1170 DWDialog *dwwait; |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1171 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
|
1172 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1173 entrywindow = dw_window_new(HWND_DESKTOP, title, flStyle); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1174 |
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
|
1175 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
|
1176 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1177 dw_box_pack_start(entrywindow, mainbox, 0, 0, TRUE, 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
|
1178 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1179 /* Archive Name */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1180 stext = dw_text_new(text, 0); |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1181 dw_window_set_style(stext, DW_DT_WORDBREAK, DW_DT_WORDBREAK); |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1182 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1183 dw_box_pack_start(mainbox, stext, 205, 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
|
1184 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1185 /* 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
|
1186 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
|
1187 |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1188 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
|
1189 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1190 yesbutton = dw_button_new("Yes", 1001L); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1191 |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1192 dw_box_pack_start(buttonbox, yesbutton, 50, 30, TRUE, FALSE, 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
|
1193 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1194 nobutton = dw_button_new("No", 1002L); |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1195 |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1196 dw_box_pack_start(buttonbox, nobutton, 50, 30, TRUE, FALSE, 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 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
|
1199 |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
1200 dw_signal_connect(yesbutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_yes_func), (void *)dwwait); |
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
1201 dw_signal_connect(nobutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_no_func), (void *)dwwait); |
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 |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1203 x = (dw_screen_width() - 220)/2; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1204 y = (dw_screen_height() - 110)/2; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1205 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1206 dw_window_set_pos_size(entrywindow, x, y, 220, 110); |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1207 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1208 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
|
1209 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1210 return (int)dw_dialog_wait(dwwait);; |
3 | 1211 } |
1212 | |
1213 /* | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1214 * 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
|
1215 * Parameters: |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1216 * handle: The window handle to minimize. |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1217 */ |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1218 int dw_window_minimize(HWND handle) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1219 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1220 int _locked_by_me = FALSE; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1221 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1222 if(!handle) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1223 return 0; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1224 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1225 DW_MUTEX_LOCK; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1226 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
|
1227 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
|
1228 DefaultScreen (GDK_DISPLAY ())); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1229 DW_MUTEX_UNLOCK; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1230 return 0; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1231 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1232 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1233 /* |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1234 * Makes the window topmost. |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1235 * Parameters: |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1236 * 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
|
1237 */ |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1238 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
|
1239 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1240 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
|
1241 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1242 if(!handle) |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1243 return 0; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1244 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1245 DW_MUTEX_LOCK; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1246 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
|
1247 DW_MUTEX_UNLOCK; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1248 return 0; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1249 } |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1250 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1251 /* |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1252 * Makes the window bottommost. |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1253 * Parameters: |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1254 * 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
|
1255 */ |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1256 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
|
1257 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1258 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
|
1259 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1260 if(!handle) |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1261 return 0; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1262 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1263 DW_MUTEX_LOCK; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1264 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
|
1265 DW_MUTEX_UNLOCK; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1266 return 0; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1267 } |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1268 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
1269 /* |
3 | 1270 * Makes the window visible. |
1271 * Parameters: | |
1272 * handle: The window handle to make visible. | |
1273 */ | |
1274 int dw_window_show(HWND handle) | |
1275 { | |
1276 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
|
1277 GtkWidget *defaultitem; |
3 | 1278 |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1279 if(!handle) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1280 return 0; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1281 |
3 | 1282 DW_MUTEX_LOCK; |
1283 gtk_widget_show(handle); | |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1284 if(GTK_WIDGET(handle)->window) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1285 { |
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
|
1286 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
|
1287 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
|
1288 |
49ac97060328
Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
271
diff
changeset
|
1289 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
|
1290 { |
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
|
1291 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
|
1292 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
|
1293 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
|
1294 } |
49ac97060328
Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
271
diff
changeset
|
1295 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1296 gdk_window_raise(GTK_WIDGET(handle)->window); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1297 gdk_flush(); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1298 gdk_window_show(GTK_WIDGET(handle)->window); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1299 gdk_flush(); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
1300 } |
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
|
1301 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
|
1302 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
|
1303 gtk_widget_grab_focus(defaultitem); |
3 | 1304 DW_MUTEX_UNLOCK; |
1305 return 0; | |
1306 } | |
1307 | |
1308 /* | |
1309 * Makes the window invisible. | |
1310 * Parameters: | |
1311 * handle: The window handle to make visible. | |
1312 */ | |
1313 int dw_window_hide(HWND handle) | |
1314 { | |
1315 int _locked_by_me = FALSE; | |
1316 | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1317 if(!handle) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1318 return 0; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1319 |
3 | 1320 DW_MUTEX_LOCK; |
1321 gtk_widget_hide(handle); | |
1322 DW_MUTEX_UNLOCK; | |
1323 return 0; | |
1324 } | |
1325 | |
1326 /* | |
1327 * Destroys a window and all of it's children. | |
1328 * Parameters: | |
1329 * handle: The window handle to destroy. | |
1330 */ | |
1331 int dw_window_destroy(HWND handle) | |
1332 { | |
1333 int _locked_by_me = FALSE; | |
1334 | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1335 if(!handle) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1336 return 0; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1337 |
3 | 1338 DW_MUTEX_LOCK; |
17
f26eced21a30
Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
15
diff
changeset
|
1339 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
|
1340 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
1341 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
|
1342 |
5df54ebc44dd
Fixed a bug where the eventbox associated with a box was not destroyed
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
355
diff
changeset
|
1343 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
|
1344 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
|
1345 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
|
1346 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
|
1347 } |
3 | 1348 DW_MUTEX_UNLOCK; |
1349 return 0; | |
1350 } | |
1351 | |
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
|
1352 /* 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
|
1353 * 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
|
1354 * 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
|
1355 */ |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
1356 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
|
1357 { |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
1358 } |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
1359 |
3 | 1360 /* |
1361 * Changes a window's parent to newparent. | |
1362 * Parameters: | |
1363 * handle: The window handle to destroy. | |
1364 * newparent: The window's new parent window. | |
1365 */ | |
1366 void dw_window_reparent(HWND handle, HWND newparent) | |
1367 { | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1368 int _locked_by_me = FALSE; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1369 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1370 DW_MUTEX_LOCK; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1371 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
|
1372 DW_MUTEX_UNLOCK; |
3 | 1373 } |
1374 | |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
1375 static int _set_font(HWND handle, char *fontname) |
3 | 1376 { |
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
|
1377 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
|
1378 #if GTK_MAJOR_VERSION < 2 |
3 | 1379 GtkStyle *style; |
1380 GdkFont *font = NULL; | |
1381 | |
1382 font = gdk_font_load(fontname); | |
1383 | |
1384 if(font) | |
1385 { | |
1386 style = gtk_widget_get_style(handle); | |
1387 style->font = font; | |
1388 gtk_widget_set_style(handle, style); | |
1389 retval = TRUE; | |
1390 } | |
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
|
1391 #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
|
1392 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
|
1393 |
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
|
1394 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
|
1395 { |
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
|
1396 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
|
1397 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
|
1398 } |
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
|
1399 #endif |
3 | 1400 return retval; |
1401 } | |
1402 | |
1403 /* | |
1404 * Sets the font used by a specified window (widget) handle. | |
1405 * Parameters: | |
1406 * handle: The window (widget) handle. | |
1407 * fontname: Name and size of the font in the form "size.fontname" | |
1408 */ | |
1409 int dw_window_set_font(HWND handle, char *fontname) | |
1410 { | |
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
|
1411 #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
|
1412 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
|
1413 #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
|
1414 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
|
1415 #endif |
3 | 1416 GtkWidget *handle2 = handle; |
1417 char *font; | |
1418 int _locked_by_me = FALSE; | |
1419 gpointer data; | |
1420 | |
1421 DW_MUTEX_LOCK; | |
1422 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
1423 { | |
1424 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
1425 if(tmp) | |
1426 handle2 = tmp; | |
1427 } | |
1428 font = strdup(fontname); | |
1429 | |
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
|
1430 #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
|
1431 /* 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
|
1432 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
|
1433 if(gdkfont) |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1434 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
|
1435 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
|
1436 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
|
1437 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
|
1438 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
|
1439 #endif |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1440 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
1441 /* 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
|
1442 data = gtk_object_get_data(GTK_OBJECT(handle2), "_dw_fontname"); |
3 | 1443 if(data) |
1444 free(data); | |
1445 | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
1446 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
|
1447 #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
|
1448 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
|
1449 |
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
|
1450 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
|
1451 { |
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
|
1452 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
|
1453 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
|
1454 } |
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 |
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
|
1456 DW_MUTEX_UNLOCK; |
3 | 1457 return TRUE; |
1458 } | |
1459 | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1460 void _free_gdk_colors(HWND handle) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1461 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
1462 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
|
1463 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1464 if(old) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1465 free(old); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1466 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
1467 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
|
1468 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1469 if(old) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1470 free(old); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1471 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1472 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1473 /* 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
|
1474 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
|
1475 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1476 GdkColor *foregdk = malloc(sizeof(GdkColor)); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1477 GdkColor *backgdk = malloc(sizeof(GdkColor)); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1478 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1479 _free_gdk_colors(handle); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1480 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1481 *foregdk = fore; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1482 *backgdk = back; |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1483 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
1484 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
|
1485 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
|
1486 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1487 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
1488 static int _set_color(HWND handle, unsigned long fore, unsigned long back) |
3 | 1489 { |
155
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1490 /* 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
|
1491 * 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
|
1492 */ |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1493 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
|
1494 #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
|
1495 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
|
1496 #endif |
3 | 1497 |
155
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1498 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
|
1499 { |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1500 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
|
1501 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
|
1502 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
|
1503 forecolor.blue = DW_BLUE_VALUE(fore) << 8; |
3 | 1504 |
1505 gdk_color_alloc(_dw_cmap, &forecolor); | |
1506 | |
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
|
1507 #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
|
1508 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
|
1509 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
|
1510 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
|
1511 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
|
1512 #else |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1513 if(style) |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1514 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
|
1515 #endif |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1516 } |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1517 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
|
1518 { |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1519 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
|
1520 |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1521 #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
|
1522 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
|
1523 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
|
1524 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
|
1525 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
|
1526 #else |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1527 if(style) |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1528 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
|
1529 #endif |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1530 } |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1531 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
|
1532 { |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1533 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
|
1534 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
|
1535 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
|
1536 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
|
1537 |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1538 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
|
1539 |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1540 #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
|
1541 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
|
1542 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
|
1543 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
|
1544 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
|
1545 #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
|
1546 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
|
1547 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
|
1548 #endif |
155
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1549 } |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1550 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
|
1551 { |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1552 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
|
1553 |
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
|
1554 #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
|
1555 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
|
1556 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
|
1557 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
|
1558 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
|
1559 #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
|
1560 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
|
1561 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
|
1562 #endif |
155
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1563 } |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1564 |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1565 _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
|
1566 |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1567 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
|
1568 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
1569 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
|
1570 |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1571 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
|
1572 { |
155
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1573 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
|
1574 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
|
1575 } |
3 | 1576 } |
1577 | |
155
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1578 #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
|
1579 if(style) |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1580 { |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1581 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
|
1582 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
|
1583 } |
840c54766306
Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
153
diff
changeset
|
1584 #endif |
3 | 1585 return TRUE; |
1586 } | |
1587 /* | |
1588 * Sets the colors used by a specified window (widget) handle. | |
1589 * Parameters: | |
1590 * handle: The window (widget) handle. | |
1591 * fore: Foreground color in RGB format. | |
1592 * back: Background color in RGB format. | |
1593 */ | |
1594 int dw_window_set_color(HWND handle, unsigned long fore, unsigned long back) | |
1595 { | |
1596 GtkWidget *handle2 = handle; | |
1597 int _locked_by_me = FALSE; | |
1598 | |
1599 DW_MUTEX_LOCK; | |
1600 | |
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
|
1601 if(GTK_IS_SCROLLED_WINDOW(handle) || GTK_IS_BOX(handle)) |
3 | 1602 { |
1603 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
1604 if(tmp) | |
1605 handle2 = tmp; | |
1606 } | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1607 else if(GTK_IS_TABLE(handle)) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
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 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
|
1610 if(tmp) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1611 handle2 = tmp; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1612 } |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1613 |
3 | 1614 _set_color(handle2, fore, back); |
1615 | |
1616 DW_MUTEX_UNLOCK; | |
1617 return TRUE; | |
1618 } | |
1619 | |
1620 /* | |
1621 * Sets the font used by a specified window (widget) handle. | |
1622 * Parameters: | |
1623 * handle: The window (widget) handle. | |
1624 * border: Size of the window border in pixels. | |
1625 */ | |
1626 int dw_window_set_border(HWND handle, int border) | |
1627 { | |
1628 /* TODO */ | |
1629 return 0; | |
1630 } | |
1631 | |
1632 /* | |
1633 * Captures the mouse input to this window. | |
1634 * Parameters: | |
1635 * handle: Handle to receive mouse input. | |
1636 */ | |
1637 void dw_window_capture(HWND handle) | |
1638 { | |
1639 int _locked_by_me = FALSE; | |
1640 | |
1641 DW_MUTEX_LOCK; | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1642 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 | 1643 DW_MUTEX_UNLOCK; |
1644 } | |
1645 | |
1646 /* | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1647 * 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
|
1648 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1649 * 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
|
1650 * 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
|
1651 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1652 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
|
1653 { |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1654 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
|
1655 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
|
1656 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1657 DW_MUTEX_LOCK; |
337
e9a424e641ff
Some pointer changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
331
diff
changeset
|
1658 if(pointertype & (1 << 31)) |
e9a424e641ff
Some pointer changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
331
diff
changeset
|
1659 { |
e9a424e641ff
Some pointer changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
331
diff
changeset
|
1660 GdkBitmap *bitmap = NULL; |
338 | 1661 GdkPixmap *pixmap = _find_private_pixmap(&bitmap, (pointertype & 0xFFFFFF), NULL, NULL); |
1662 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
|
1663 } |
e9a424e641ff
Some pointer changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
331
diff
changeset
|
1664 else |
e9a424e641ff
Some pointer changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
331
diff
changeset
|
1665 cursor = gdk_cursor_new(pointertype); |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
1666 if(handle && handle->window) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
1667 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
|
1668 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
|
1669 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
|
1670 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1671 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
1672 /* |
3 | 1673 * Releases previous mouse capture. |
1674 */ | |
1675 void dw_window_release(void) | |
1676 { | |
1677 int _locked_by_me = FALSE; | |
1678 | |
1679 DW_MUTEX_LOCK; | |
1680 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
1681 DW_MUTEX_UNLOCK; | |
1682 } | |
1683 | |
1684 /* | |
1685 * Create a new Window Frame. | |
1686 * Parameters: | |
1687 * owner: The Owner's window handle or HWND_DESKTOP. | |
1688 * title: The Window title. | |
1689 * flStyle: Style flags, see the PM reference. | |
1690 */ | |
1691 HWND dw_window_new(HWND hwndOwner, char *title, unsigned long flStyle) | |
1692 { | |
1693 GtkWidget *tmp; | |
1694 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
|
1695 int flags = 0; |
3 | 1696 |
1697 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
|
1698 last_window = tmp = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
3 | 1699 |
1700 gtk_window_set_title(GTK_WINDOW(tmp), title); | |
1701 if(!(flStyle & DW_FCF_SIZEBORDER)) | |
1702 gtk_window_set_policy(GTK_WINDOW(tmp), FALSE, FALSE, TRUE); | |
1703 | |
1704 gtk_widget_realize(tmp); | |
1705 | |
1706 if(flStyle & DW_FCF_TITLEBAR) | |
1707 flags |= GDK_DECOR_TITLE; | |
1708 | |
1709 if(flStyle & DW_FCF_MINMAX) | |
1710 flags |= GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE; | |
1711 | |
1712 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
|
1713 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
|
1714 |
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
|
1715 if(flStyle & DW_FCF_BORDER || flStyle & DW_FCF_DLGBORDER) |
3 | 1716 flags |= GDK_DECOR_BORDER; |
1717 | |
1718 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
|
1719 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1720 if(hwndOwner) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1721 gdk_window_reparent(GTK_WIDGET(tmp)->window, GTK_WIDGET(hwndOwner)->window, 0, 0); |
3 | 1722 |
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
|
1723 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
|
1724 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
|
1725 |
3 | 1726 DW_MUTEX_UNLOCK; |
1727 return tmp; | |
1728 } | |
1729 | |
1730 /* | |
1731 * Create a new Box to be packed. | |
1732 * 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
|
1733 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal). |
3 | 1734 * pad: Number of pixels to pad around the box. |
1735 */ | |
1736 HWND dw_box_new(int type, int pad) | |
1737 { | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1738 GtkWidget *tmp, *eventbox; |
3 | 1739 int _locked_by_me = FALSE; |
1740 | |
1741 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
|
1742 tmp = gtk_table_new(1, 1, FALSE); |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1743 eventbox = gtk_event_box_new(); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1744 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1745 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
|
1746 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
|
1747 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
|
1748 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_boxpad", (gpointer)pad); |
3 | 1749 gtk_widget_show(tmp); |
1750 DW_MUTEX_UNLOCK; | |
1751 return tmp; | |
1752 } | |
1753 | |
1754 /* | |
1755 * Create a new Group Box to be packed. | |
1756 * 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
|
1757 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal). |
3 | 1758 * pad: Number of pixels to pad around the box. |
1759 * title: Text to be displayined in the group outline. | |
1760 */ | |
1761 HWND dw_groupbox_new(int type, int pad, char *title) | |
1762 { | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1763 GtkWidget *tmp, *frame; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1764 int _locked_by_me = FALSE; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1765 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1766 DW_MUTEX_LOCK; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1767 frame = gtk_frame_new(NULL); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1768 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
|
1769 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
|
1770 tmp = gtk_table_new(1, 1, FALSE); |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
1771 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
|
1772 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
|
1773 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
|
1774 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
|
1775 gtk_container_add(GTK_CONTAINER(frame), tmp); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1776 gtk_widget_show(tmp); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1777 gtk_widget_show(frame); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1778 DW_MUTEX_UNLOCK; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
1779 return frame; |
3 | 1780 } |
1781 | |
1782 /* | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1783 * 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
|
1784 * Parameters: |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1785 * 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
|
1786 */ |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1787 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
|
1788 { |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1789 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
|
1790 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
|
1791 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1792 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
|
1793 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
|
1794 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
|
1795 return tmp; |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1796 } |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1797 |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
1798 /* |
3 | 1799 * Create a bitmap object to be packed. |
1800 * 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
|
1801 * id: An ID to be used with dw_window_from_id() or 0L. |
3 | 1802 */ |
1803 HWND dw_bitmap_new(unsigned long id) | |
1804 { | |
121
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
1805 #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
|
1806 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
|
1807 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
|
1808 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
|
1809 "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
|
1810 " 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
|
1811 ". 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
|
1812 "."}; |
121
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
1813 #endif |
d8af32b1b1cd
Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
120
diff
changeset
|
1814 GtkWidget *tmp; |
3 | 1815 int _locked_by_me = FALSE; |
1816 | |
1817 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
|
1818 #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
|
1819 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
|
1820 #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
|
1821 gdk_imlib_data_to_pixmap(test_xpm, &pixmap, &bitmap); |
3 | 1822 #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
|
1823 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
|
1824 |
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
|
1825 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
|
1826 pixmap = gdk_pixmap_create_from_xpm_d(last_window->window, &bitmap, &_colors[DW_CLR_PALEGRAY], test_xpm); |
3 | 1827 #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
|
1828 #if GTK_MAJOR_VERSION < 2 |
3 | 1829 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
|
1830 #endif |
3 | 1831 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
|
1832 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
3 | 1833 DW_MUTEX_UNLOCK; |
1834 return tmp; | |
1835 } | |
1836 | |
1837 /* | |
1838 * Create a notebook object to be packed. | |
1839 * Parameters: | |
1840 * id: An ID to be used for getting the resource from the | |
1841 * resource file. | |
1842 */ | |
1843 HWND dw_notebook_new(unsigned long id, int top) | |
1844 { | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
1845 GtkWidget *tmp, **pagearray = calloc(sizeof(GtkWidget *), 256); |
3 | 1846 int _locked_by_me = FALSE; |
1847 | |
1848 DW_MUTEX_LOCK; | |
1849 tmp = gtk_notebook_new(); | |
1850 if(top) | |
1851 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(tmp), GTK_POS_TOP); | |
1852 else | |
1853 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
|
1854 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
|
1855 #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
|
1856 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
|
1857 #endif |
3 | 1858 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
|
1859 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
|
1860 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_pagearray", (gpointer)pagearray); |
3 | 1861 DW_MUTEX_UNLOCK; |
1862 return tmp; | |
1863 } | |
1864 | |
1865 /* | |
1866 * Create a menu object to be popped up. | |
1867 * Parameters: | |
1868 * id: An ID to be used for getting the resource from the | |
1869 * resource file. | |
1870 */ | |
1871 HMENUI dw_menu_new(unsigned long id) | |
1872 { | |
1873 int _locked_by_me = FALSE; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1874 GtkAccelGroup *accel_group; |
185
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
1875 HMENUI tmp; |
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
1876 |
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
1877 DW_MUTEX_LOCK; |
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
1878 tmp = gtk_menu_new(); |
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
1879 gtk_widget_show(tmp); |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1880 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
|
1881 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
|
1882 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_accel", (gpointer)accel_group); |
3 | 1883 DW_MUTEX_UNLOCK; |
1884 return tmp; | |
1885 } | |
1886 | |
1887 /* | |
1888 * Create a menubar on a window. | |
1889 * Parameters: | |
1890 * location: Handle of a window frame to be attached to. | |
1891 */ | |
1892 HMENUI dw_menubar_new(HWND location) | |
1893 { | |
1894 GtkWidget *box; | |
1895 int _locked_by_me = FALSE; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1896 GtkAccelGroup *accel_group; |
185
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
1897 HMENUI tmp; |
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
1898 |
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
1899 DW_MUTEX_LOCK; |
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
1900 tmp = gtk_menu_bar_new(); |
3 | 1901 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
|
1902 gtk_widget_show(tmp); |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1903 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
|
1904 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_accel", (gpointer)accel_group); |
3 | 1905 |
1906 if(box) | |
185
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
1907 gtk_box_pack_end(GTK_BOX(box), tmp, FALSE, FALSE, 0); |
3 | 1908 |
1909 DW_MUTEX_UNLOCK; | |
1910 return tmp; | |
1911 } | |
1912 | |
1913 /* | |
1914 * Destroys a menu created with dw_menubar_new or dw_menu_new. | |
1915 * Parameters: | |
1916 * menu: Handle of a menu. | |
1917 */ | |
1918 void dw_menu_destroy(HMENUI *menu) | |
1919 { | |
1920 if(menu && *menu) | |
1921 { | |
1922 int _locked_by_me = FALSE; | |
1923 | |
1924 DW_MUTEX_LOCK; | |
185
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
1925 gtk_widget_destroy(*menu); |
3 | 1926 *menu = NULL; |
1927 DW_MUTEX_UNLOCK; | |
1928 } | |
1929 } | |
1930 | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1931 char _removetilde(char *dest, char *src) |
3 | 1932 { |
1933 int z, cur=0; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1934 char accel = '\0'; |
3 | 1935 |
1936 for(z=0;z<strlen(src);z++) | |
1937 { | |
1938 if(src[z] != '~') | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1939 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1940 dest[cur] = src[z]; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1941 cur++; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1942 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1943 else |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1944 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1945 dest[cur] = '_'; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1946 accel = src[z+1]; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1947 cur++; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1948 } |
3 | 1949 } |
1950 dest[cur] = 0; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1951 return accel; |
3 | 1952 } |
1953 | |
1954 /* | |
1955 * Adds a menuitem or submenu to an existing menu. | |
1956 * Parameters: | |
1957 * menu: The handle the the existing menu. | |
1958 * title: The title text on the menu item to be added. | |
1959 * id: An ID to be used for message passing. | |
1960 * flags: Extended attributes to set on the menu. | |
1961 * end: If TRUE memu is positioned at the end of the menu. | |
1962 * check: If TRUE menu is "check"able. | |
1963 * submenu: Handle to an existing menu to be a submenu or NULL. | |
1964 */ | |
1965 HWND dw_menu_append_item(HMENUI menu, char *title, unsigned long id, unsigned long flags, int end, int check, HMENUI submenu) | |
1966 { | |
1967 GtkWidget *tmphandle; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1968 char accel, *tempbuf = malloc(strlen(title)+1); |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
1969 int _locked_by_me = FALSE, submenucount; |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1970 guint tmp_key; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1971 GtkAccelGroup *accel_group; |
3 | 1972 |
185
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
1973 if(!menu) |
3 | 1974 { |
1975 free(tempbuf); | |
1976 return NULL; | |
1977 } | |
1978 | |
1979 DW_MUTEX_LOCK; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1980 accel = _removetilde(tempbuf, title); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1981 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
1982 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
|
1983 submenucount = (int)gtk_object_get_data(GTK_OBJECT(menu), "_dw_submenucount"); |
3 | 1984 |
1985 if(strlen(tempbuf) == 0) | |
1986 tmphandle=gtk_menu_item_new(); | |
1987 else | |
1988 { | |
1989 if(check) | |
1990 { | |
1991 char numbuf[10]; | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1992 if(accel && accel_group) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1993 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1994 tmphandle=gtk_check_menu_item_new_with_label(""); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1995 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
|
1996 #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
|
1997 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
|
1998 #endif |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
1999 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2000 else |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2001 tmphandle=gtk_check_menu_item_new_with_label(tempbuf); |
3 | 2002 gtk_check_menu_item_set_show_toggle(GTK_CHECK_MENU_ITEM(tmphandle), TRUE); |
2003 sprintf(numbuf, "%lu", id); | |
185
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
2004 gtk_object_set_data(GTK_OBJECT(menu), numbuf, (gpointer)tmphandle); |
3 | 2005 } |
2006 else | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2007 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2008 if(accel && accel_group) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2009 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2010 tmphandle=gtk_menu_item_new_with_label(""); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2011 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
|
2012 #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
|
2013 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
|
2014 #endif |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2015 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2016 else |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2017 tmphandle=gtk_menu_item_new_with_label(tempbuf); |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2018 } |
3 | 2019 } |
2020 | |
2021 gtk_widget_show(tmphandle); | |
2022 | |
2023 if(submenu) | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2024 { |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2025 char tempbuf[100]; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2026 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2027 sprintf(tempbuf, "_dw_submenu%d", submenucount); |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2028 submenucount++; |
185
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
2029 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
|
2030 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
|
2031 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
|
2032 } |
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
2033 |
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
2034 if(GTK_IS_MENU_BAR(menu)) |
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
2035 gtk_menu_bar_append(GTK_MENU_BAR(menu), tmphandle); |
3 | 2036 else |
185
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
2037 gtk_menu_append(GTK_MENU(menu), tmphandle); |
3 | 2038 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2039 gtk_object_set_data(GTK_OBJECT(tmphandle), "_dw_id", (gpointer)id); |
3 | 2040 free(tempbuf); |
2041 DW_MUTEX_UNLOCK; | |
2042 return tmphandle; | |
2043 } | |
2044 | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2045 GtkWidget *_find_submenu_id(GtkWidget *start, char *name) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2046 { |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2047 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
|
2048 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
|
2049 |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2050 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
|
2051 return tmp; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2052 |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2053 for(z=0;z<submenucount;z++) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2054 { |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2055 char tempbuf[100]; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2056 GtkWidget *submenu, *menuitem; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2057 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2058 sprintf(tempbuf, "_dw_submenu%d", z); |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2059 |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2060 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
|
2061 { |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2062 if((menuitem = _find_submenu_id(submenu, name))) |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2063 return menuitem; |
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 } |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2066 return NULL; |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2067 } |
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2068 |
3 | 2069 /* |
2070 * Sets the state of a menu item check. | |
2071 * Parameters: | |
2072 * menu: The handle the the existing menu. | |
2073 * id: Menuitem id. | |
2074 * check: TRUE for checked FALSE for not checked. | |
2075 */ | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2076 void dw_menu_item_set_check(HMENUI menu, unsigned long id, int check) |
3 | 2077 { |
2078 char numbuf[10]; | |
2079 GtkWidget *tmphandle; | |
2080 int _locked_by_me = FALSE; | |
2081 | |
185
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
2082 if(!menu) |
3 | 2083 return; |
2084 | |
2085 DW_MUTEX_LOCK; | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
2086 sprintf(numbuf, "%lu", id); |
185
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
2087 tmphandle = _find_submenu_id(menu, numbuf); |
3 | 2088 |
2089 if(tmphandle) | |
2090 { | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2091 _dw_ignore_click = 1; |
3 | 2092 if(GTK_CHECK_MENU_ITEM(tmphandle)->active != check) |
2093 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
|
2094 _dw_ignore_click = 0; |
3 | 2095 } |
2096 DW_MUTEX_UNLOCK; | |
2097 } | |
2098 | |
2099 /* | |
2100 * Pops up a context menu at given x and y coordinates. | |
2101 * Parameters: | |
2102 * menu: The handle the the existing menu. | |
2103 * parent: Handle to the window initiating the popup. | |
2104 * x: X coordinate. | |
2105 * y: Y coordinate. | |
2106 */ | |
2107 void dw_menu_popup(HMENUI *menu, HWND parent, int x, int y) | |
2108 { | |
2109 int _locked_by_me = FALSE; | |
2110 | |
2111 if(!menu || !*menu) | |
2112 return; | |
2113 | |
93
98cce029a611
Changed handling of menu item click events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
92
diff
changeset
|
2114 popup = parent; |
98cce029a611
Changed handling of menu item click events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
92
diff
changeset
|
2115 |
3 | 2116 DW_MUTEX_LOCK; |
185
f55677513954
Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
167
diff
changeset
|
2117 gtk_menu_popup(GTK_MENU(*menu), NULL, NULL, NULL, NULL, 1, GDK_CURRENT_TIME); |
3 | 2118 *menu = NULL; |
2119 DW_MUTEX_UNLOCK; | |
2120 } | |
2121 | |
2122 | |
2123 /* | |
2124 * Returns the current X and Y coordinates of the mouse pointer. | |
2125 * Parameters: | |
2126 * x: Pointer to variable to store X coordinate. | |
2127 * y: Pointer to variable to store Y coordinate. | |
2128 */ | |
2129 void dw_pointer_query_pos(long *x, long *y) | |
2130 { | |
2131 GdkModifierType state; | |
2132 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
|
2133 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
|
2134 |
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
|
2135 DW_MUTEX_LOCK; |
3 | 2136 gdk_window_get_pointer (GDK_ROOT_PARENT(), &gx, &gy, &state); |
2137 *x = gx; | |
2138 *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
|
2139 DW_MUTEX_UNLOCK; |
3 | 2140 } |
2141 | |
2142 /* | |
2143 * Sets the X and Y coordinates of the mouse pointer. | |
2144 * Parameters: | |
2145 * x: X coordinate. | |
2146 * y: Y coordinate. | |
2147 */ | |
2148 void dw_pointer_set_pos(long x, long y) | |
2149 { | |
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
|
2150 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
|
2151 |
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
|
2152 DW_MUTEX_LOCK; |
3 | 2153 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
|
2154 DW_MUTEX_UNLOCK; |
3 | 2155 } |
2156 | |
2157 /* | |
2158 * Create a container object to be packed. | |
2159 * Parameters: | |
2160 * id: An ID to be used for getting the resource from the | |
2161 * resource file. | |
2162 */ | |
350
2216e65ad2ae
Removed slider flags and container selection flags from the header file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
346
diff
changeset
|
2163 HWND dw_container_new(unsigned long id, int multi) |
3 | 2164 { |
2165 GtkWidget *tmp; | |
2166 int _locked_by_me = FALSE; | |
2167 | |
2168 DW_MUTEX_LOCK; | |
2169 tmp = gtk_scrolled_window_new (NULL, NULL); | |
2170 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (tmp), | |
2171 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
2172 | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2173 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
|
2174 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
3 | 2175 gtk_widget_show(tmp); |
2176 | |
2177 DW_MUTEX_UNLOCK; | |
2178 return tmp; | |
2179 } | |
2180 | |
2181 /* | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2182 * 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
|
2183 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2184 * 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
|
2185 * 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
|
2186 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2187 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
|
2188 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2189 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
|
2190 #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
|
2191 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
|
2192 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
|
2193 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
|
2194 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
|
2195 #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
|
2196 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
|
2197 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2198 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
|
2199 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
|
2200 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
|
2201 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
|
2202 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2203 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
|
2204 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
|
2205 #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
|
2206 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
|
2207 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
|
2208 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
|
2209 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
|
2210 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
2211 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
|
2212 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
|
2213 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
|
2214 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
|
2215 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
|
2216 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
|
2217 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
2218 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
|
2219 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
|
2220 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
|
2221 |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
2222 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
|
2223 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
|
2224 #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
|
2225 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
|
2226 #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
|
2227 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
|
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 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
|
2230 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
|
2231 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
|
2232 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2233 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
|
2234 #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
|
2235 /* 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
|
2236 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
|
2237 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
|
2238 #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
|
2239 |
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_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
|
2241 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
|
2242 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2243 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
|
2244 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
|
2245 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2246 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2247 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
2248 /* |
3 | 2249 * Create a new static text window (widget) to be packed. |
2250 * Parameters: | |
2251 * 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
|
2252 * id: An ID to be used with dw_window_from_id() or 0L. |
3 | 2253 */ |
2254 HWND dw_text_new(char *text, unsigned long id) | |
2255 { | |
2256 GtkWidget *tmp; | |
2257 int _locked_by_me = FALSE; | |
2258 | |
2259 DW_MUTEX_LOCK; | |
2260 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
|
2261 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2262 /* 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
|
2263 gtk_misc_set_alignment(GTK_MISC(tmp), 0.0f, 0.5f); |
3 | 2264 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
|
2265 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
|
2266 gtk_misc_set_alignment(GTK_MISC(tmp), DW_LEFT, DW_LEFT); |
3 | 2267 DW_MUTEX_UNLOCK; |
2268 return tmp; | |
2269 } | |
2270 | |
2271 /* | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2272 * 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
|
2273 * Parameters: |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2274 * 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
|
2275 * 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
|
2276 */ |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2277 HWND dw_status_text_new(char *text, ULONG id) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2278 { |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2279 GtkWidget *tmp, *frame; |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2280 int _locked_by_me = FALSE; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2281 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2282 DW_MUTEX_LOCK; |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2283 frame = gtk_frame_new(NULL); |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2284 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
|
2285 tmp = gtk_label_new(text); |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2286 gtk_container_add(GTK_CONTAINER(frame), tmp); |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2287 gtk_widget_show(tmp); |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2288 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
|
2289 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2290 /* 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
|
2291 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
|
2292 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
|
2293 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
|
2294 DW_MUTEX_UNLOCK; |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2295 return frame; |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2296 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2297 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
2298 /* |
3 | 2299 * Create a new Multiline Editbox window (widget) to be packed. |
2300 * 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
|
2301 * id: An ID to be used with dw_window_from_id() or 0L. |
3 | 2302 */ |
2303 HWND dw_mle_new(unsigned long id) | |
2304 { | |
2305 GtkWidget *tmp, *tmpbox, *scroller; | |
2306 int _locked_by_me = FALSE; | |
2307 | |
2308 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
|
2309 #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
|
2310 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
|
2311 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
|
2312 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
|
2313 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
|
2314 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
|
2315 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
|
2316 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
|
2317 |
122
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
2318 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
|
2319 #else |
3 | 2320 tmpbox = gtk_hbox_new(FALSE, 0); |
2321 tmp = gtk_text_new(NULL, NULL); | |
2322 gtk_text_set_word_wrap(GTK_TEXT(tmp), FALSE); | |
2323 gtk_text_set_line_wrap(GTK_TEXT(tmp), FALSE); | |
2324 scroller = gtk_vscrollbar_new(GTK_TEXT(tmp)->vadj); | |
2325 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
|
2326 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
|
2327 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
|
2328 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
|
2329 #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
|
2330 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
|
2331 gtk_object_set_user_data(GTK_OBJECT(tmpbox), (gpointer)tmp); |
3 | 2332 gtk_widget_show(tmp); |
2333 gtk_widget_show(tmpbox); | |
2334 DW_MUTEX_UNLOCK; | |
2335 return tmpbox; | |
2336 } | |
2337 | |
2338 /* | |
2339 * Create a new Entryfield window (widget) to be packed. | |
2340 * Parameters: | |
2341 * 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
|
2342 * id: An ID to be used with dw_window_from_id() or 0L. |
3 | 2343 */ |
2344 HWND dw_entryfield_new(char *text, unsigned long id) | |
2345 { | |
2346 GtkWidget *tmp; | |
2347 int _locked_by_me = FALSE; | |
2348 | |
2349 DW_MUTEX_LOCK; | |
2350 tmp = gtk_entry_new(); | |
2351 | |
2352 gtk_entry_set_text(GTK_ENTRY(tmp), text); | |
2353 | |
2354 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
|
2355 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
3 | 2356 |
2357 DW_MUTEX_UNLOCK; | |
2358 return tmp; | |
2359 } | |
2360 | |
2361 /* | |
2362 * Create a new Entryfield (password) window (widget) to be packed. | |
2363 * Parameters: | |
2364 * 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
|
2365 * id: An ID to be used with dw_window_from_id() or 0L. |
3 | 2366 */ |
2367 HWND dw_entryfield_password_new(char *text, ULONG id) | |
2368 { | |
2369 GtkWidget *tmp; | |
2370 int _locked_by_me = FALSE; | |
2371 | |
2372 DW_MUTEX_LOCK; | |
2373 tmp = gtk_entry_new(); | |
2374 | |
2375 gtk_entry_set_visibility(GTK_ENTRY(tmp), FALSE); | |
2376 gtk_entry_set_text(GTK_ENTRY(tmp), text); | |
2377 | |
2378 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
|
2379 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
3 | 2380 |
2381 DW_MUTEX_UNLOCK; | |
2382 return tmp; | |
2383 } | |
2384 | |
2385 /* | |
2386 * Create a new Combobox window (widget) to be packed. | |
2387 * Parameters: | |
2388 * 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
|
2389 * id: An ID to be used with dw_window_from_id() or 0L. |
3 | 2390 */ |
2391 HWND dw_combobox_new(char *text, unsigned long id) | |
2392 { | |
2393 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
|
2394 SignalHandler *work = malloc(sizeof(SignalHandler)); |
3 | 2395 int _locked_by_me = FALSE; |
2396 | |
2397 DW_MUTEX_LOCK; | |
2398 tmp = gtk_combo_new(); | |
2399 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(tmp)->entry), text); | |
2400 gtk_combo_set_use_arrows(GTK_COMBO(tmp), TRUE); | |
2401 gtk_object_set_user_data(GTK_OBJECT(tmp), NULL); | |
2402 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
|
2403 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
|
2404 |
2d121d4d90c0
Run the _item_select_event() handler on comboboxes even if a handler
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
114
diff
changeset
|
2405 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
|
2406 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
|
2407 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
|
2408 |
2d121d4d90c0
Run the _item_select_event() handler on comboboxes even if a handler
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
114
diff
changeset
|
2409 gtk_signal_connect(GTK_OBJECT(GTK_COMBO(tmp)->list), "select_child", GTK_SIGNAL_FUNC(_item_select_event), work); |
3 | 2410 DW_MUTEX_UNLOCK; |
2411 return tmp; | |
2412 } | |
2413 | |
2414 /* | |
2415 * Create a new button window (widget) to be packed. | |
2416 * Parameters: | |
2417 * 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
|
2418 * id: An ID to be used with dw_window_from_id() or 0L. |
3 | 2419 */ |
2420 HWND dw_button_new(char *text, unsigned long id) | |
2421 { | |
2422 GtkWidget *tmp; | |
2423 int _locked_by_me = FALSE; | |
2424 | |
2425 DW_MUTEX_LOCK; | |
2426 tmp = gtk_button_new_with_label(text); | |
2427 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
|
2428 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
3 | 2429 DW_MUTEX_UNLOCK; |
2430 return tmp; | |
2431 } | |
2432 | |
2433 /* | |
2434 * Create a new bitmap button window (widget) to be packed. | |
2435 * Parameters: | |
2436 * text: Bubble help text to be displayed. | |
2437 * id: An ID of a bitmap in the resource file. | |
2438 */ | |
2439 HWND dw_bitmapbutton_new(char *text, unsigned long id) | |
2440 { | |
2441 GtkWidget *tmp; | |
2442 GtkWidget *bitmap; | |
2443 GtkTooltips *tooltips; | |
2444 int _locked_by_me = FALSE; | |
2445 | |
2446 DW_MUTEX_LOCK; | |
2447 tmp = gtk_button_new(); | |
2448 bitmap = dw_bitmap_new(id); | |
2449 | |
2450 if(bitmap) | |
2451 { | |
278
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2452 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
|
2453 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
|
2454 } |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2455 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
|
2456 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
|
2457 { |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2458 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
|
2459 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
|
2460 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
|
2461 } |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2462 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
|
2463 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
|
2464 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
|
2465 } |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2466 |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2467 /* |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2468 * 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
|
2469 * Parameters: |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2470 * 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
|
2471 * 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
|
2472 * 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
|
2473 * 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
|
2474 * (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
|
2475 */ |
279
984db8aefd7f
Build fixes for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
278
diff
changeset
|
2476 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
|
2477 { |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2478 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
|
2479 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
|
2480 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
|
2481 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
|
2482 |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2483 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
|
2484 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
|
2485 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
|
2486 |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2487 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
|
2488 { |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2489 dw_window_set_bitmap(bitmap, 0, filename); |
3 | 2490 gtk_container_add (GTK_CONTAINER(tmp), bitmap); |
2491 } | |
2492 gtk_widget_show(tmp); | |
2493 if(text) | |
2494 { | |
2495 tooltips = gtk_tooltips_new(); | |
2496 gtk_tooltips_set_tip(tooltips, tmp, text, NULL); | |
2497 gtk_object_set_data(GTK_OBJECT(tmp), "tooltip", (gpointer)tooltips); | |
2498 } | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2499 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
3 | 2500 DW_MUTEX_UNLOCK; |
2501 return tmp; | |
2502 } | |
2503 | |
2504 /* | |
2505 * Create a new spinbutton window (widget) to be packed. | |
2506 * Parameters: | |
2507 * 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
|
2508 * id: An ID to be used with dw_window_from_id() or 0L. |
3 | 2509 */ |
2510 HWND dw_spinbutton_new(char *text, unsigned long id) | |
2511 { | |
2512 GtkAdjustment *adj; | |
2513 GtkWidget *tmp; | |
2514 int _locked_by_me = FALSE; | |
2515 | |
2516 DW_MUTEX_LOCK; | |
2517 adj = (GtkAdjustment *)gtk_adjustment_new (1.0, 0.0, 100.0, 1.0, 5.0, 0.0); | |
2518 tmp = gtk_spin_button_new (adj, 0, 0); | |
2519 gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(tmp), TRUE); | |
2520 gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(tmp), TRUE); | |
2521 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
|
2522 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
3 | 2523 DW_MUTEX_UNLOCK; |
2524 return tmp; | |
2525 } | |
2526 | |
2527 /* | |
2528 * Create a new radiobutton window (widget) to be packed. | |
2529 * Parameters: | |
2530 * 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
|
2531 * id: An ID to be used with dw_window_from_id() or 0L. |
3 | 2532 */ |
2533 HWND dw_radiobutton_new(char *text, ULONG id) | |
2534 { | |
2535 /* This will have to be fixed in the future. */ | |
2536 GtkWidget *tmp; | |
2537 int _locked_by_me = FALSE; | |
2538 | |
2539 DW_MUTEX_LOCK; | |
2540 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
|
2541 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
3 | 2542 gtk_widget_show(tmp); |
2543 | |
2544 DW_MUTEX_UNLOCK; | |
2545 return tmp; | |
2546 } | |
2547 | |
2548 /* | |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2549 * 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
|
2550 * Parameters: |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2551 * 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
|
2552 * 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
|
2553 * 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
|
2554 */ |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2555 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
|
2556 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2557 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
|
2558 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
|
2559 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
|
2560 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2561 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
|
2562 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
|
2563 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
|
2564 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
|
2565 else |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2566 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
|
2567 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
|
2568 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
|
2569 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
|
2570 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
|
2571 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
|
2572 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
|
2573 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
|
2574 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
|
2575 } |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2576 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
2577 /* |
195
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2578 * 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
|
2579 * Parameters: |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2580 * 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
|
2581 * 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
|
2582 * 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
|
2583 */ |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2584 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
|
2585 { |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2586 GtkWidget *tmp; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2587 GtkAdjustment *adjustment; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2588 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
|
2589 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2590 DW_MUTEX_LOCK; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2591 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
|
2592 if(vertical) |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2593 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
|
2594 else |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2595 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
|
2596 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
|
2597 gtk_widget_show(tmp); |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2598 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_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
|
2599 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
|
2600 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
|
2601 DW_MUTEX_UNLOCK; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2602 return tmp; |
196
3dc60d60007f
Fixed a missing bracket.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
195
diff
changeset
|
2603 } |
195
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2604 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
2605 /* |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
2606 * Create a new percent bar window (widget) to be packed. |
3 | 2607 * 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
|
2608 * id: An ID to be used with dw_window_from_id() or 0L. |
3 | 2609 */ |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
2610 HWND dw_percent_new(unsigned long id) |
3 | 2611 { |
2612 GtkWidget *tmp; | |
2613 int _locked_by_me = FALSE; | |
2614 | |
2615 DW_MUTEX_LOCK; | |
2616 tmp = gtk_progress_bar_new(); | |
2617 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
|
2618 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
3 | 2619 DW_MUTEX_UNLOCK; |
2620 return tmp; | |
2621 } | |
2622 | |
2623 /* | |
2624 * Create a new checkbox window (widget) to be packed. | |
2625 * Parameters: | |
2626 * 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
|
2627 * id: An ID to be used with dw_window_from_id() or 0L. |
3 | 2628 */ |
2629 HWND dw_checkbox_new(char *text, unsigned long id) | |
2630 { | |
2631 GtkWidget *tmp; | |
2632 int _locked_by_me = FALSE; | |
2633 | |
2634 DW_MUTEX_LOCK; | |
2635 tmp = gtk_check_button_new_with_label(text); | |
2636 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
|
2637 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
3 | 2638 DW_MUTEX_UNLOCK; |
2639 return tmp; | |
2640 } | |
2641 | |
2642 /* | |
2643 * Create a new listbox window (widget) to be packed. | |
2644 * 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
|
2645 * id: An ID to be used with dw_window_from_id() or 0L. |
3 | 2646 * multi: Multiple select TRUE or FALSE. |
2647 */ | |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2648 HWND dw_listbox_new(unsigned long id, int multi) |
3 | 2649 { |
2650 GtkWidget *tmp, *list; | |
2651 int _locked_by_me = FALSE; | |
2652 | |
2653 DW_MUTEX_LOCK; | |
2654 tmp = gtk_scrolled_window_new(NULL, NULL); | |
2655 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (tmp), | |
2656 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
2657 | |
2658 list = gtk_list_new(); | |
2659 gtk_list_set_selection_mode(GTK_LIST(list), multi ? GTK_SELECTION_MULTIPLE : GTK_SELECTION_SINGLE); | |
2660 | |
2661 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(tmp), | |
2662 list); | |
2663 gtk_object_set_user_data(GTK_OBJECT(tmp), list); | |
2664 gtk_widget_show(list); | |
2665 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
|
2666 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id); |
3 | 2667 |
2668 DW_MUTEX_UNLOCK; | |
2669 return tmp; | |
2670 } | |
2671 | |
2672 /* | |
2673 * Sets the icon used for a given window. | |
2674 * Parameters: | |
2675 * handle: Handle to the window. | |
2676 * id: An ID to be used to specify the icon. | |
2677 */ | |
2678 void dw_window_set_icon(HWND handle, unsigned long id) | |
2679 { | |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2680 GdkBitmap *bitmap = NULL; |
3 | 2681 GdkPixmap *icon_pixmap; |
2682 int _locked_by_me = FALSE; | |
2683 | |
2684 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
|
2685 icon_pixmap = _find_pixmap(&bitmap, id, handle, NULL, NULL); |
3 | 2686 |
2687 if(handle->window && icon_pixmap) | |
2688 gdk_window_set_icon(handle->window, NULL, icon_pixmap, bitmap); | |
2689 | |
2690 DW_MUTEX_UNLOCK; | |
2691 } | |
2692 | |
2693 /* | |
2694 * Sets the bitmap used for a given static window. | |
2695 * Parameters: | |
2696 * 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
|
2697 * 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
|
2698 * (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
|
2699 * 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
|
2700 * 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
|
2701 * 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
|
2702 */ |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2703 void dw_window_set_bitmap(HWND handle, unsigned long id, char *filename) |
3 | 2704 { |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
2705 GdkBitmap *bitmap = NULL; |
3 | 2706 GdkPixmap *tmp; |
2707 int _locked_by_me = FALSE; | |
2708 | |
278
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2709 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
|
2710 return; |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2711 |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2712 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
|
2713 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
|
2714 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
|
2715 else |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2716 { |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2717 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
|
2718 #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
|
2719 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
|
2720 #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
|
2721 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
|
2722 #endif |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2723 |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2724 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
|
2725 { |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2726 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
|
2727 return; |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2728 } |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2729 |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2730 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
|
2731 |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2732 /* 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
|
2733 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
|
2734 { |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2735 /* 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
|
2736 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
|
2737 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
|
2738 { |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2739 DW_MUTEX_UNLOCK; |
279
984db8aefd7f
Build fixes for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
278
diff
changeset
|
2740 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
|
2741 } |
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 #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
|
2744 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
|
2745 |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2746 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
|
2747 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
|
2748 #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
|
2749 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
|
2750 |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2751 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
|
2752 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
|
2753 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
|
2754 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
|
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 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
|
2757 #endif |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2758 } |
df0665ba147f
Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
273
diff
changeset
|
2759 |
3 | 2760 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
|
2761 #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
|
2762 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
|
2763 #else |
3 | 2764 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
|
2765 #endif |
3 | 2766 DW_MUTEX_UNLOCK; |
2767 } | |
2768 | |
2769 /* | |
2770 * Sets the text used for a given window. | |
2771 * Parameters: | |
2772 * handle: Handle to the window. | |
2773 * text: The text associsated with a given window. | |
2774 */ | |
2775 void dw_window_set_text(HWND handle, char *text) | |
2776 { | |
2777 int _locked_by_me = FALSE; | |
2778 | |
2779 DW_MUTEX_LOCK; | |
2780 if(GTK_IS_ENTRY(handle)) | |
2781 gtk_entry_set_text(GTK_ENTRY(handle), text); | |
2782 else if(GTK_IS_COMBO(handle)) | |
2783 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(handle)->entry), text); | |
2784 else if(GTK_IS_LABEL(handle)) | |
2785 gtk_label_set_text(GTK_LABEL(handle), text); | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2786 else if(GTK_IS_FRAME(handle)) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2787 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2788 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
|
2789 if(tmp && GTK_IS_LABEL(tmp)) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
2790 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
|
2791 } |
3 | 2792 DW_MUTEX_UNLOCK; |
2793 } | |
2794 | |
2795 /* | |
2796 * Gets the text used for a given window. | |
2797 * Parameters: | |
2798 * handle: Handle to the window. | |
2799 * Returns: | |
2800 * text: The text associsated with a given window. | |
2801 */ | |
2802 char *dw_window_get_text(HWND handle) | |
2803 { | |
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
|
2804 #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
|
2805 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
|
2806 #else |
3 | 2807 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
|
2808 #endif |
3 | 2809 int _locked_by_me = FALSE; |
2810 | |
2811 DW_MUTEX_LOCK; | |
2812 if(GTK_IS_ENTRY(handle)) | |
2813 possible = gtk_entry_get_text(GTK_ENTRY(handle)); | |
2814 else if(GTK_IS_COMBO(handle)) | |
2815 possible = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(handle)->entry)); | |
2816 | |
2817 DW_MUTEX_UNLOCK; | |
2818 return strdup(possible); | |
2819 } | |
2820 | |
2821 /* | |
2822 * Disables given window (widget). | |
2823 * Parameters: | |
2824 * handle: Handle to the window. | |
2825 */ | |
2826 void dw_window_disable(HWND handle) | |
2827 { | |
2828 int _locked_by_me = FALSE; | |
2829 | |
2830 DW_MUTEX_LOCK; | |
2831 gtk_widget_set_sensitive(handle, FALSE); | |
2832 DW_MUTEX_UNLOCK; | |
2833 } | |
2834 | |
2835 /* | |
2836 * Enables given window (widget). | |
2837 * Parameters: | |
2838 * handle: Handle to the window. | |
2839 */ | |
2840 void dw_window_enable(HWND handle) | |
2841 { | |
2842 int _locked_by_me = FALSE; | |
2843 | |
2844 DW_MUTEX_LOCK; | |
2845 gtk_widget_set_sensitive(handle, TRUE); | |
2846 DW_MUTEX_UNLOCK; | |
2847 } | |
2848 | |
249
5a594058687f
Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
246
diff
changeset
|
2849 /* |
5a594058687f
Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
246
diff
changeset
|
2850 * 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
|
2851 * Parameters: |
5a594058687f
Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
246
diff
changeset
|
2852 * 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
|
2853 * 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
|
2854 */ |
5a594058687f
Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
246
diff
changeset
|
2855 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
|
2856 { |
267
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2857 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
|
2858 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
|
2859 |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2860 DW_MUTEX_LOCK; |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2861 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
|
2862 { |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2863 #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
|
2864 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
|
2865 #else |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2866 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
|
2867 #endif |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2868 } |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2869 while(list) |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2870 { |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2871 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
|
2872 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2873 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
|
2874 { |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2875 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
|
2876 g_list_free(orig); |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2877 DW_MUTEX_UNLOCK; |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2878 return ret; |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2879 } |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2880 } |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2881 list = list->next; |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2882 } |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2883 if(orig) |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2884 g_list_free(orig); |
bf8b907f8a29
Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
265
diff
changeset
|
2885 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
|
2886 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
|
2887 } |
5a594058687f
Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
246
diff
changeset
|
2888 |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2889 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
|
2890 { |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2891 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
|
2892 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2893 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
|
2894 { |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2895 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
|
2896 { |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2897 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
|
2898 x++; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2899 } |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2900 } |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2901 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
|
2902 } |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2903 |
3 | 2904 /* |
2905 * Adds text to an MLE box and returns the current point. | |
2906 * Parameters: | |
2907 * handle: Handle to the MLE to be queried. | |
2908 * buffer: Text buffer to be imported. | |
2909 * startpoint: Point to start entering text. | |
2910 */ | |
2911 unsigned int dw_mle_import(HWND handle, char *buffer, int startpoint) | |
2912 { | |
2913 unsigned int tmppoint = startpoint; | |
2914 int _locked_by_me = FALSE; | |
2915 | |
2916 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
|
2917 #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
|
2918 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
|
2919 #else |
3 | 2920 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
|
2921 #endif |
3 | 2922 { |
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
|
2923 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 2924 |
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
|
2925 #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
|
2926 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
|
2927 { |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2928 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
|
2929 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
|
2930 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
|
2931 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2932 _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
|
2933 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2934 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
|
2935 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
|
2936 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
|
2937 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
|
2938 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
|
2939 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
|
2940 } |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
2941 #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
|
2942 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
|
2943 |
3 | 2944 if(tmp && GTK_IS_TEXT(tmp)) |
2945 { | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
2946 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
|
2947 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
|
2948 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
|
2949 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
2950 _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
|
2951 |
3 | 2952 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
|
2953 gtk_text_insert(GTK_TEXT(tmp), font, fore, back, impbuf, -1); |
3 | 2954 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
|
2955 free(impbuf); |
3 | 2956 } |
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
|
2957 #endif |
3 | 2958 } |
2959 DW_MUTEX_UNLOCK; | |
2960 return tmppoint; | |
2961 } | |
2962 | |
2963 /* | |
2964 * Grabs text from an MLE box. | |
2965 * Parameters: | |
2966 * handle: Handle to the MLE to be queried. | |
2967 * buffer: Text buffer to be exported. | |
2968 * startpoint: Point to start grabbing text. | |
2969 * length: Amount of text to be grabbed. | |
2970 */ | |
2971 void dw_mle_export(HWND handle, char *buffer, int startpoint, int length) | |
2972 { | |
2973 int _locked_by_me = FALSE; | |
2974 gchar *text; | |
2975 | |
2976 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
|
2977 #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
|
2978 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
|
2979 #else |
3 | 2980 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
|
2981 #endif |
3 | 2982 { |
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
|
2983 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 2984 |
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
|
2985 #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
|
2986 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
|
2987 { |
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
|
2988 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
|
2989 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
|
2990 |
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
|
2991 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
|
2992 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
|
2993 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
|
2994 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
|
2995 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
|
2996 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
|
2997 } |
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
|
2998 #else |
3 | 2999 if(tmp && GTK_IS_TEXT(tmp)) |
3000 { | |
3001 text = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), startpoint, startpoint + length); | |
3002 if(text) | |
3003 { | |
3004 strcpy(buffer, text); | |
3005 g_free(text); | |
3006 } | |
3007 } | |
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
|
3008 #endif |
3 | 3009 } |
3010 DW_MUTEX_UNLOCK; | |
3011 } | |
3012 | |
3013 /* | |
3014 * Obtains information about an MLE box. | |
3015 * Parameters: | |
3016 * handle: Handle to the MLE to be queried. | |
3017 * bytes: A pointer to a variable to return the total bytes. | |
3018 * lines: A pointer to a variable to return the number of lines. | |
3019 */ | |
3020 void dw_mle_query(HWND handle, unsigned long *bytes, unsigned long *lines) | |
3021 { | |
3022 int _locked_by_me = FALSE; | |
3023 | |
3024 if(bytes) | |
3025 *bytes = 0; | |
3026 if(lines) | |
3027 *lines = 0; | |
3028 | |
3029 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
|
3030 #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
|
3031 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
|
3032 { |
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
|
3033 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
|
3034 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3035 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
|
3036 { |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3037 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
|
3038 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3039 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
|
3040 *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
|
3041 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
|
3042 *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
|
3043 } |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3044 } |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3045 #else |
3 | 3046 if(GTK_IS_BOX(handle)) |
3047 { | |
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
|
3048 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 3049 |
3050 if(tmp && GTK_IS_TEXT(tmp)) | |
3051 { | |
3052 if(bytes) | |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3053 *bytes = gtk_text_get_length(GTK_TEXT(tmp)) + 1; |
3 | 3054 if(lines) |
3055 { | |
3056 gchar *text; | |
3057 | |
3058 *lines = 0; | |
3059 text = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), 0, bytes ? *bytes : gtk_text_get_length(GTK_TEXT(tmp))); | |
3060 | |
3061 if(text) | |
3062 { | |
3063 int z, len = strlen(text); | |
3064 | |
3065 for(z=0;z<len;z++) | |
3066 { | |
3067 if(text[z] == '\n') | |
3068 (*lines)++; | |
3069 } | |
3070 g_free(text); | |
3071 } | |
3072 } | |
3073 } | |
3074 } | |
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
|
3075 #endif |
3 | 3076 DW_MUTEX_UNLOCK; |
3077 } | |
3078 | |
3079 /* | |
3080 * Deletes text from an MLE box. | |
3081 * Parameters: | |
3082 * handle: Handle to the MLE to be deleted from. | |
3083 * startpoint: Point to start deleting text. | |
3084 * length: Amount of text to be deleted. | |
3085 */ | |
3086 void dw_mle_delete(HWND handle, int startpoint, int length) | |
3087 { | |
3088 int _locked_by_me = FALSE; | |
3089 | |
3090 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
|
3091 #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
|
3092 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
|
3093 #else |
3 | 3094 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
|
3095 #endif |
3 | 3096 { |
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
|
3097 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 3098 |
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
|
3099 #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
|
3100 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
|
3101 { |
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
|
3102 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
|
3103 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
|
3104 |
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
|
3105 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
|
3106 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
|
3107 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
|
3108 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
|
3109 } |
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
|
3110 #else |
3 | 3111 if(tmp && GTK_IS_TEXT(tmp)) |
3112 { | |
3113 gtk_text_set_point(GTK_TEXT(tmp), startpoint); | |
3114 gtk_text_forward_delete(GTK_TEXT(tmp), length); | |
3115 } | |
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
|
3116 #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
|
3117 } |
3 | 3118 DW_MUTEX_UNLOCK; |
3119 } | |
3120 | |
3121 /* | |
3122 * Clears all text from an MLE box. | |
3123 * Parameters: | |
3124 * handle: Handle to the MLE to be cleared. | |
3125 */ | |
3126 void dw_mle_clear(HWND handle) | |
3127 { | |
3128 int length, _locked_by_me = FALSE; | |
3129 | |
3130 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
|
3131 #if GTK_MAJOR_VERSION > 1 |
122
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3132 if(GTK_IS_SCROLLED_WINDOW(handle)) |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3133 { |
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
|
3134 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
|
3135 |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3136 if(tmp && GTK_IS_TEXT_VIEW(tmp)) |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3137 { |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3138 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
|
3139 |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3140 length = -1; |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3141 gtk_text_buffer_set_text(buffer, "", length); |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3142 } |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
3143 } |
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)) |
3146 { | |
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
|
3147 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 3148 |
3149 if(tmp && GTK_IS_TEXT(tmp)) | |
3150 { | |
3151 length = gtk_text_get_length(GTK_TEXT(tmp)); | |
3152 gtk_text_set_point(GTK_TEXT(tmp), 0); | |
3153 gtk_text_forward_delete(GTK_TEXT(tmp), length); | |
3154 } | |
3155 } | |
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
|
3156 #endif |
3 | 3157 DW_MUTEX_UNLOCK; |
3158 } | |
3159 | |
3160 /* | |
3161 * Sets the visible line of an MLE box. | |
3162 * Parameters: | |
3163 * handle: Handle to the MLE. | |
3164 * line: Line to be visible. | |
3165 */ | |
3166 void dw_mle_set_visible(HWND handle, int line) | |
3167 { | |
3168 int _locked_by_me = FALSE; | |
3169 | |
3170 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
|
3171 #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
|
3172 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
|
3173 { |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3174 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
|
3175 |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3176 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
|
3177 { |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3178 GtkTextBuffer *tbuffer; |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3179 GtkTextIter iter; |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3180 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
|
3181 |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3182 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
|
3183 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
|
3184 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
|
3185 if(!mark) |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3186 { |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3187 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
|
3188 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
|
3189 } |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3190 else |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3191 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
|
3192 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
|
3193 0, FALSE, 0, 0); |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3194 } |
3a51ecc8383a
Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
353
diff
changeset
|
3195 } |
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
|
3196 #else |
3 | 3197 if(GTK_IS_BOX(handle)) |
3198 { | |
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
|
3199 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 3200 |
3201 if(tmp && GTK_IS_TEXT(tmp)) | |
3202 { | |
3203 unsigned long lines; | |
3204 float pos, ratio; | |
3205 | |
3206 dw_mle_query(handle, NULL, &lines); | |
3207 | |
3208 if(lines) | |
3209 { | |
3210 ratio = (float)line/(float)lines; | |
3211 | |
3212 pos = (ratio * (float)(GTK_TEXT(tmp)->vadj->upper - GTK_TEXT(tmp)->vadj->lower)) + GTK_TEXT(tmp)->vadj->lower; | |
3213 | |
3214 gtk_adjustment_set_value(GTK_TEXT(tmp)->vadj, pos); | |
3215 } | |
3216 } | |
3217 } | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3218 #endif |
3 | 3219 DW_MUTEX_UNLOCK; |
3220 } | |
3221 | |
3222 /* | |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3223 * Sets the editablity of an MLE box. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3224 * Parameters: |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3225 * handle: Handle to the MLE. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3226 * 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
|
3227 */ |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3228 void dw_mle_set_editable(HWND handle, int state) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3229 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3230 int _locked_by_me = FALSE; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3231 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3232 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
|
3233 #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
|
3234 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
|
3235 { |
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
|
3236 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
|
3237 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3238 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
|
3239 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
|
3240 } |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3241 #else |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3242 if(GTK_IS_BOX(handle)) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3243 { |
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
|
3244 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
|
3245 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3246 if(tmp && GTK_IS_TEXT(tmp)) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3247 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
|
3248 } |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3249 #endif |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3250 DW_MUTEX_UNLOCK; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3251 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3252 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3253 /* |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3254 * Sets the word wrap state of an MLE box. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3255 * Parameters: |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3256 * handle: Handle to the MLE. |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3257 * 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
|
3258 */ |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3259 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
|
3260 { |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3261 int _locked_by_me = FALSE; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3262 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3263 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
|
3264 #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
|
3265 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
|
3266 { |
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
|
3267 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
|
3268 |
7d2108cbcd3e
Porting DW 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 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
|
3270 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
|
3271 } |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3272 #else |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3273 if(GTK_IS_BOX(handle)) |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3274 { |
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
|
3275 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
|
3276 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3277 if(tmp && GTK_IS_TEXT(tmp)) |
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 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
|
3280 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
|
3281 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3282 } |
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
|
3283 #endif |
7
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3284 DW_MUTEX_UNLOCK; |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3285 } |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3286 |
005fa766e8c2
Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
3
diff
changeset
|
3287 /* |
3 | 3288 * Sets the current cursor position of an MLE box. |
3289 * Parameters: | |
3290 * handle: Handle to the MLE to be positioned. | |
3291 * point: Point to position cursor. | |
3292 */ | |
3293 void dw_mle_set(HWND handle, int point) | |
3294 { | |
3295 int _locked_by_me = FALSE; | |
3296 | |
3297 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
|
3298 #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
|
3299 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
|
3300 #else |
3 | 3301 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
|
3302 #endif |
3 | 3303 { |
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
|
3304 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 3305 |
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
|
3306 #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
|
3307 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
|
3308 { |
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
|
3309 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
|
3310 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
|
3311 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
|
3312 |
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
|
3313 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
|
3314 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
|
3315 if(!mark) |
08e56a0f9541
dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
352
diff
changeset
|
3316 { |
08e56a0f9541
dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
352
diff
changeset
|
3317 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
|
3318 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
|
3319 } |
08e56a0f9541
dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
352
diff
changeset
|
3320 else |
08e56a0f9541
dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
352
diff
changeset
|
3321 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
|
3322 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
|
3323 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
|
3324 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
|
3325 } |
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
|
3326 #else |
3 | 3327 if(tmp && GTK_IS_TEXT(tmp)) |
3328 { | |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3329 unsigned long chars; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3330 float pos, ratio; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3331 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3332 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
|
3333 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3334 if(chars) |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3335 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3336 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
|
3337 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3338 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
|
3339 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
3340 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
|
3341 } |
3 | 3342 gtk_text_set_point(GTK_TEXT(tmp), point); |
3343 } | |
120
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
3344 #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
|
3345 } |
3 | 3346 DW_MUTEX_UNLOCK; |
3347 } | |
3348 | |
3349 /* | |
3350 * Finds text in an MLE box. | |
3351 * Parameters: | |
3352 * handle: Handle to the MLE to be cleared. | |
3353 * text: Text to search for. | |
3354 * point: Start point of search. | |
3355 * flags: Search specific flags. | |
3356 */ | |
3357 int dw_mle_search(HWND handle, char *text, int point, unsigned long flags) | |
3358 { | |
3359 int _locked_by_me = FALSE, retval = 0; | |
3360 | |
3361 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
|
3362 #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
|
3363 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
|
3364 #else |
3 | 3365 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
|
3366 #endif |
3 | 3367 { |
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
|
3368 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 3369 |
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
|
3370 #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
|
3371 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
|
3372 { |
54014258099a
Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
122
diff
changeset
|
3373 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
|
3374 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
|
3375 |
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 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
|
3377 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
|
3378 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
|
3379 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
|
3380 } |
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
|
3381 #else |
3 | 3382 if(tmp && GTK_IS_TEXT(tmp)) |
3383 { | |
3384 int len = gtk_text_get_length(GTK_TEXT(tmp)); | |
3385 gchar *tmpbuf; | |
3386 | |
3387 tmpbuf = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), 0, len); | |
3388 if(tmpbuf) | |
3389 { | |
3390 int z, textlen; | |
3391 | |
3392 textlen = strlen(text); | |
3393 | |
3394 if(flags & DW_MLE_CASESENSITIVE) | |
3395 { | |
3396 for(z=point;z<(len-textlen) && !retval;z++) | |
3397 { | |
3398 if(strncmp(&tmpbuf[z], text, textlen) == 0) | |
3399 retval = z + textlen; | |
3400 } | |
3401 } | |
3402 else | |
3403 { | |
3404 for(z=point;z<(len-textlen) && !retval;z++) | |
3405 { | |
3406 if(strncasecmp(&tmpbuf[z], text, textlen) == 0) | |
3407 retval = z + textlen; | |
3408 } | |
3409 } | |
3410 | |
3411 if(retval) | |
3412 { | |
3413 gtk_text_set_point(GTK_TEXT(tmp), retval - textlen); | |
3414 gtk_editable_select_region(&(GTK_TEXT(tmp)->editable), retval - textlen, retval); | |
3415 } | |
3416 | |
3417 g_free(tmpbuf); | |
3418 } | |
3419 } | |
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
|
3420 #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
|
3421 } |
3 | 3422 DW_MUTEX_UNLOCK; |
3423 return retval; | |
3424 } | |
3425 | |
3426 /* | |
3427 * Stops redrawing of an MLE box. | |
3428 * Parameters: | |
3429 * handle: Handle to the MLE to freeze. | |
3430 */ | |
3431 void dw_mle_freeze(HWND handle) | |
3432 { | |
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
|
3433 #if GTK_MAJOR_VERSION < 2 |
3 | 3434 int _locked_by_me = FALSE; |
3435 | |
3436 DW_MUTEX_LOCK; | |
3437 if(GTK_IS_BOX(handle)) | |
3438 { | |
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
|
3439 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 3440 |
3441 if(tmp && GTK_IS_TEXT(tmp)) | |
3442 { | |
3443 gtk_text_freeze(GTK_TEXT(tmp)); | |
3444 } | |
3445 } | |
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
|
3446 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
|
3447 #endif |
3 | 3448 } |
3449 | |
3450 /* | |
3451 * Resumes redrawing of an MLE box. | |
3452 * Parameters: | |
3453 * handle: Handle to the MLE to thaw. | |
3454 */ | |
3455 void dw_mle_thaw(HWND handle) | |
3456 { | |
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
|
3457 #if GTK_MAJOR_VERSION < 2 |
3 | 3458 int _locked_by_me = FALSE; |
3459 | |
3460 DW_MUTEX_LOCK; | |
3461 if(GTK_IS_BOX(handle)) | |
3462 { | |
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
|
3463 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); |
3 | 3464 |
3465 if(tmp && GTK_IS_TEXT(tmp)) | |
3466 { | |
3467 gtk_text_thaw(GTK_TEXT(tmp)); | |
3468 } | |
3469 } | |
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
|
3470 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
|
3471 #endif |
3 | 3472 } |
3473 | |
3474 /* | |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
3475 * Returns the range of the percent bar. |
3 | 3476 * 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
|
3477 * handle: Handle to the percent bar to be queried. |
3 | 3478 */ |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
3479 unsigned int dw_percent_query_range(HWND handle) |
3 | 3480 { |
3481 return 100; | |
3482 } | |
3483 | |
3484 /* | |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
3485 * Sets the percent bar position. |
3 | 3486 * 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
|
3487 * 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
|
3488 * position: Position of the percent bar withing the range. |
3 | 3489 */ |
33
72675de7d229
Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
30
diff
changeset
|
3490 void dw_percent_set_pos(HWND handle, unsigned int position) |
3 | 3491 { |
3492 int _locked_by_me = FALSE; | |
3493 | |
3494 DW_MUTEX_LOCK; | |
3495 gtk_progress_bar_update(GTK_PROGRESS_BAR(handle), (gfloat)position/100); | |
3496 DW_MUTEX_UNLOCK; | |
3497 } | |
3498 | |
3499 /* | |
63
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3500 * 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
|
3501 * Parameters: |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3502 * 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
|
3503 */ |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3504 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
|
3505 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3506 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
|
3507 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
|
3508 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3509 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
|
3510 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
|
3511 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3512 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
|
3513 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
|
3514 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
|
3515 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3516 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
|
3517 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
|
3518 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3519 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
|
3520 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
|
3521 else |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3522 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
|
3523 } |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3524 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
|
3525 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
|
3526 } |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3527 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3528 /* |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3529 * 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
|
3530 * Parameters: |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3531 * 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
|
3532 * 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
|
3533 */ |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3534 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
|
3535 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3536 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
|
3537 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
|
3538 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3539 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
|
3540 return; |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3541 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3542 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
|
3543 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
|
3544 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
|
3545 { |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3546 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
|
3547 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3548 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
|
3549 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
|
3550 else |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3551 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
|
3552 } |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3553 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
|
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 |
a6801a2260af
Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
60
diff
changeset
|
3556 /* |
195
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3557 * 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
|
3558 * Parameters: |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3559 * 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
|
3560 */ |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3561 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
|
3562 { |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3563 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
|
3564 GtkAdjustment *adjustment; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3565 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3566 if(!handle) |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3567 return 0; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3568 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3569 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
|
3570 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
|
3571 if(adjustment) |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3572 { |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3573 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
|
3574 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
|
3575 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3576 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
|
3577 val = max - thisval; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3578 else |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3579 val = thisval; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3580 } |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3581 DW_MUTEX_UNLOCK; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3582 return val; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3583 } |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3584 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3585 /* |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3586 * 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
|
3587 * Parameters: |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3588 * 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
|
3589 * 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
|
3590 */ |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3591 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
|
3592 { |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3593 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
|
3594 GtkAdjustment *adjustment; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3595 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3596 if(!handle) |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3597 return; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3598 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3599 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
|
3600 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
|
3601 if(adjustment) |
215
03e68274623d
Two scrollbar fixes for GTK... one from Mark Hessling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
214
diff
changeset
|
3602 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
|
3603 DW_MUTEX_UNLOCK; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3604 } |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3605 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
3606 /* |
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
|
3607 * 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
|
3608 * 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
|
3609 * 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
|
3610 * 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
|
3611 * 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
|
3612 */ |
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
3613 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
|
3614 { |
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
|
3615 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
|
3616 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
|
3617 |
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
|
3618 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
|
3619 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
|
3620 |
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
|
3621 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
|
3622 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
|
3623 if(adjustment) |
205
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
3624 { |
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
3625 adjustment->upper = (gdouble)range; |
216 | 3626 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
|
3627 } |
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
|
3628 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
|
3629 } |
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
|
3630 |
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
|
3631 /* |
3 | 3632 * Sets the spinbutton value. |
3633 * Parameters: | |
3634 * handle: Handle to the spinbutton to be set. | |
3635 * position: Current value of the spinbutton. | |
3636 */ | |
3637 void dw_spinbutton_set_pos(HWND handle, long position) | |
3638 { | |
3639 int _locked_by_me = FALSE; | |
3640 | |
3641 DW_MUTEX_LOCK; | |
3642 gtk_spin_button_set_value(GTK_SPIN_BUTTON(handle), (gfloat)position); | |
3643 DW_MUTEX_UNLOCK; | |
3644 } | |
3645 | |
3646 /* | |
3647 * Sets the spinbutton limits. | |
3648 * Parameters: | |
3649 * handle: Handle to the spinbutton to be set. | |
3650 * position: Current value of the spinbutton. | |
3651 * position: Current value of the spinbutton. | |
3652 */ | |
3653 void dw_spinbutton_set_limits(HWND handle, long upper, long lower) | |
3654 { | |
3655 long curval; | |
3656 GtkAdjustment *adj; | |
3657 int _locked_by_me = FALSE; | |
3658 | |
3659 curval = dw_spinbutton_query(handle); | |
3660 DW_MUTEX_LOCK; | |
3661 adj = (GtkAdjustment *)gtk_adjustment_new((gfloat)curval, (gfloat)lower, (gfloat)upper, 1.0, 5.0, 0.0); | |
3662 DW_MUTEX_UNLOCK; | |
3663 } | |
3664 | |
3665 /* | |
3666 * Sets the entryfield character limit. | |
3667 * Parameters: | |
3668 * handle: Handle to the spinbutton to be set. | |
3669 * limit: Number of characters the entryfield will take. | |
3670 */ | |
3671 void dw_entryfield_set_limit(HWND handle, ULONG limit) | |
3672 { | |
270
d2a80e648d33
Implemented dw_entryfield_set_limit() on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
269
diff
changeset
|
3673 int _locked_by_me = FALSE; |
d2a80e648d33
Implemented dw_entryfield_set_limit() on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
269
diff
changeset
|
3674 |
d2a80e648d33
Implemented dw_entryfield_set_limit() on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
269
diff
changeset
|
3675 DW_MUTEX_LOCK; |
271
38d8908c4438
Corrected incorrect typecast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
270
diff
changeset
|
3676 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
|
3677 DW_MUTEX_UNLOCK; |
3 | 3678 } |
3679 | |
3680 /* | |
3681 * Returns the current value of the spinbutton. | |
3682 * Parameters: | |
3683 * handle: Handle to the spinbutton to be queried. | |
3684 */ | |
3685 long dw_spinbutton_query(HWND handle) | |
3686 { | |
3687 long retval; | |
3688 int _locked_by_me = FALSE; | |
3689 | |
3690 DW_MUTEX_LOCK; | |
3691 retval = (long)gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(handle)); | |
3692 DW_MUTEX_UNLOCK; | |
3693 | |
3694 return retval; | |
3695 } | |
3696 | |
3697 /* | |
3698 * Returns the state of the checkbox. | |
3699 * Parameters: | |
3700 * handle: Handle to the checkbox to be queried. | |
3701 */ | |
3702 int dw_checkbox_query(HWND handle) | |
3703 { | |
3704 int retval; | |
3705 int _locked_by_me = FALSE; | |
3706 | |
3707 DW_MUTEX_LOCK; | |
3708 retval = GTK_TOGGLE_BUTTON(handle)->active; | |
3709 DW_MUTEX_UNLOCK; | |
3710 | |
3711 return retval; | |
3712 } | |
3713 | |
3714 /* | |
3715 * Sets the state of the checkbox. | |
3716 * Parameters: | |
3717 * handle: Handle to the checkbox to be queried. | |
3718 * value: TRUE for checked, FALSE for unchecked. | |
3719 */ | |
3720 void dw_checkbox_set(HWND handle, int value) | |
3721 { | |
3722 int _locked_by_me = FALSE; | |
3723 | |
3724 DW_MUTEX_LOCK; | |
3725 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(handle), value); | |
3726 DW_MUTEX_UNLOCK; | |
3727 } | |
3728 | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3729 /* |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3730 * 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
|
3731 * Parameters: |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3732 * 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
|
3733 * 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
|
3734 * title: The text title of the entry. |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3735 * icon: Handle to coresponding icon. |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3736 * parent: Parent handle or 0 if root. |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3737 * itemdata: Item specific data. |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3738 */ |
329
9b1953ed0bff
Oops missed one parameter change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
328
diff
changeset
|
3739 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
|
3740 { |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3741 #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
|
3742 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
|
3743 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
|
3744 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
|
3745 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
|
3746 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
|
3747 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
|
3748 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3749 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
|
3750 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
|
3751 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3752 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
|
3753 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
|
3754 && 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
|
3755 (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
|
3756 { |
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
|
3757 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
|
3758 |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3759 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
|
3760 |
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
|
3761 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
|
3762 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
|
3763 if(pixbuf) |
63d68387d924
Don't unref a non-existant pixmap. (GTK 2.x)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
255
diff
changeset
|
3764 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
|
3765 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
|
3766 } |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3767 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
|
3768 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3769 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
|
3770 #else |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3771 GtkWidget *newitem, *tree, *subtree, *label, *hbox, *pixmap; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3772 GdkPixmap *gdkpix; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3773 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
|
3774 int position = -1; |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3775 int _locked_by_me = FALSE; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3776 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3777 if(!handle) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3778 return NULL; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3779 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3780 DW_MUTEX_LOCK; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3781 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
|
3782 if(!tree || !GTK_IS_TREE(tree)) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3783 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3784 DW_MUTEX_UNLOCK; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3785 return NULL; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3786 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3787 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3788 if(item && GTK_IS_TREE_ITEM(item)) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3789 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
|
3790 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3791 position++; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3792 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3793 newitem = gtk_tree_item_new(); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3794 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
|
3795 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
|
3796 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
|
3797 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
|
3798 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
|
3799 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
|
3800 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
|
3801 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
|
3802 if(gdkpix) |
a167001c56df
Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
249
diff
changeset
|
3803 { |
a167001c56df
Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
249
diff
changeset
|
3804 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
|
3805 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
|
3806 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
|
3807 } |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3808 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
|
3809 gtk_widget_show(label); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3810 gtk_widget_show(hbox); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3811 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3812 if(parent) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3813 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3814 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
|
3815 if(!subtree) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3816 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
3817 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
|
3818 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
|
3819 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
|
3820 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3821 subtree = gtk_tree_new(); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3822 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3823 if(thisfunc && work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3824 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3825 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
|
3826 (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
|
3827 } |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3828 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
3829 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
|
3830 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
|
3831 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
|
3832 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3833 if(thisfunc && work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3834 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3835 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
|
3836 (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
|
3837 } |
60
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 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
|
3840 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
|
3841 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
|
3842 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
|
3843 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
|
3844 gtk_widget_show(subtree); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3845 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
|
3846 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
|
3847 } |
358
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_parenttree", (gpointer)subtree); |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3849 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
|
3850 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3851 else |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3852 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
3853 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
|
3854 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
|
3855 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3856 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
|
3857 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
|
3858 gtk_widget_show(newitem); |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3859 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
|
3860 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
|
3861 #endif |
60
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 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3864 /* |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3865 * 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
|
3866 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3867 * 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
|
3868 * 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
|
3869 * 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
|
3870 * 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
|
3871 * 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
|
3872 */ |
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
|
3873 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
|
3874 { |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3875 #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
|
3876 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
|
3877 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
|
3878 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
|
3879 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
|
3880 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
|
3881 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
|
3882 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3883 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
|
3884 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
|
3885 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3886 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
|
3887 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
|
3888 && 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
|
3889 (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
|
3890 { |
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
|
3891 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
|
3892 |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3893 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
|
3894 |
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
|
3895 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
|
3896 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
|
3897 if(pixbuf) |
63d68387d924
Don't unref a non-existant pixmap. (GTK 2.x)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
255
diff
changeset
|
3898 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
|
3899 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
|
3900 } |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3901 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
|
3902 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
3903 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
|
3904 #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
|
3905 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
|
3906 GdkPixmap *gdkpix; |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3907 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
|
3908 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
|
3909 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3910 if(!handle) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3911 return NULL; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3912 |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3913 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
|
3914 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
|
3915 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
|
3916 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3917 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
|
3918 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
|
3919 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3920 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
|
3921 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
|
3922 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
|
3923 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
|
3924 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
|
3925 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
|
3926 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
|
3927 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
|
3928 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
|
3929 if(gdkpix) |
a167001c56df
Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
249
diff
changeset
|
3930 { |
a167001c56df
Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
249
diff
changeset
|
3931 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
|
3932 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
|
3933 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
|
3934 } |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3935 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
|
3936 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
|
3937 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
|
3938 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3939 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
|
3940 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3941 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
|
3942 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
|
3943 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
3944 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
|
3945 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
|
3946 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
|
3947 |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3948 subtree = gtk_tree_new(); |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3949 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3950 if(thisfunc && work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3951 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3952 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
|
3953 (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
|
3954 } |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3955 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
3956 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
|
3957 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
|
3958 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
|
3959 |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3960 if(thisfunc && work.window) |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3961 { |
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
3962 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
|
3963 (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
|
3964 } |
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
|
3965 |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3966 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
|
3967 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
|
3968 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
|
3969 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
|
3970 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
|
3971 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
|
3972 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
|
3973 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
|
3974 } |
358
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_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
|
3976 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
|
3977 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
3978 else |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
3979 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
3980 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
|
3981 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
|
3982 } |
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
|
3983 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
|
3984 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
|
3985 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
|
3986 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
|
3987 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
|
3988 #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
|
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 |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
3991 /* |
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
|
3992 * 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
|
3993 * 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
|
3994 * 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
|
3995 * 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
|
3996 * 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
|
3997 * 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
|
3998 */ |
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
|
3999 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
|
4000 { |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4001 #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
|
4002 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
|
4003 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
|
4004 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
|
4005 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
|
4006 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4007 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
|
4008 return; |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4009 |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4010 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
|
4011 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
|
4012 && 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
|
4013 (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
|
4014 { |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4015 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
|
4016 |
139
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4017 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
|
4018 if(pixbuf) |
63d68387d924
Don't unref a non-existant pixmap. (GTK 2.x)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
255
diff
changeset
|
4019 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
|
4020 } |
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4021 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
|
4022 #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
|
4023 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
|
4024 GdkPixmap *gdkpix; |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4025 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
|
4026 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
|
4027 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
|
4028 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4029 if(!handle || !item) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4030 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4031 |
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
|
4032 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
|
4033 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
|
4034 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
|
4035 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
|
4036 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
|
4037 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
|
4038 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
|
4039 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
|
4040 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
|
4041 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
|
4042 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
|
4043 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
|
4044 if(gdkpix) |
a167001c56df
Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
249
diff
changeset
|
4045 { |
a167001c56df
Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
249
diff
changeset
|
4046 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
|
4047 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
|
4048 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
|
4049 } |
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
|
4050 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
|
4051 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
|
4052 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
|
4053 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
|
4054 #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
|
4055 } |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
4056 |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
4057 /* |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
4058 * 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
|
4059 * 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
|
4060 * 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
|
4061 * 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
|
4062 * 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
|
4063 */ |
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
|
4064 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
|
4065 { |
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
|
4066 #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
|
4067 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
|
4068 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
|
4069 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
|
4070 |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
4071 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
|
4072 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
|
4073 |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
4074 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
|
4075 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
|
4076 && 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
|
4077 (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
|
4078 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
|
4079 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
|
4080 #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
|
4081 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
|
4082 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4083 if(!handle || !item) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4084 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4085 |
54
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
4086 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
|
4087 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
|
4088 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
|
4089 #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
|
4090 } |
c4e1139d9872
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 |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
4092 /* |
317
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4093 * 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
|
4094 * Parameters: |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4095 * 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
|
4096 * 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
|
4097 */ |
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
|
4098 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
|
4099 { |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4100 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
|
4101 #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
|
4102 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
|
4103 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
|
4104 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
|
4105 |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4106 if(!handle || !item) |
319
aed5d742896d
Fixed errant returns on failure.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
317
diff
changeset
|
4107 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
|
4108 |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4109 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
|
4110 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
|
4111 && 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
|
4112 (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
|
4113 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
|
4114 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
|
4115 #else |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4116 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
|
4117 |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4118 if(!handle || !item) |
319
aed5d742896d
Fixed errant returns on failure.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
317
diff
changeset
|
4119 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
|
4120 |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4121 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
|
4122 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
|
4123 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
|
4124 #endif |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4125 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
|
4126 } |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4127 |
83edbd751da9
Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
316
diff
changeset
|
4128 /* |
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
|
4129 * 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
|
4130 * 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
|
4131 * 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
|
4132 * 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
|
4133 */ |
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
|
4134 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
|
4135 { |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4136 #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
|
4137 GtkWidget *tree; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4138 GtkTreeStore *store; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4139 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
|
4140 |
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
|
4141 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
|
4142 return; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4143 |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4144 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
|
4145 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
|
4146 && 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
|
4147 (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
|
4148 { |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4149 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
|
4150 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
|
4151 |
139
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4152 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
|
4153 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
|
4154 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
|
4155 } |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4156 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
|
4157 #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
|
4158 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
|
4159 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
|
4160 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4161 if(!handle || !item) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4162 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4163 |
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
|
4164 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
|
4165 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
|
4166 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
|
4167 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
|
4168 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
|
4169 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
|
4170 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
|
4171 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
|
4172 #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
|
4173 } |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
4174 |
143
1d57c27e4adc
Moved _dw_recursive_free into GTK 2.0 #ifdefs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
142
diff
changeset
|
4175 #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
|
4176 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
|
4177 { |
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
|
4178 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
|
4179 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
|
4180 |
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
|
4181 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
|
4182 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
|
4183 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
|
4184 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
|
4185 |
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
|
4186 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
|
4187 { |
36dc19aa7773
Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
140
diff
changeset
|
4188 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
|
4189 _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
|
4190 } 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
|
4191 } |
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 } |
143
1d57c27e4adc
Moved _dw_recursive_free into GTK 2.0 #ifdefs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
142
diff
changeset
|
4193 #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
|
4194 |
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
|
4195 /* |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4196 * Removes all nodes from a tree. |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4197 * Parameters: |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4198 * 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
|
4199 */ |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4200 void dw_tree_clear(HWND handle) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4201 { |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4202 #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
|
4203 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
|
4204 GtkTreeStore *store; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4205 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
|
4206 |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4207 if(!handle) |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4208 return; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4209 |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4210 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
|
4211 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
|
4212 && 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
|
4213 (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
|
4214 { |
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
|
4215 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
|
4216 |
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
|
4217 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
|
4218 { |
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
|
4219 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
|
4220 _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
|
4221 } 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
|
4222 } |
139
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4223 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
|
4224 } |
139
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4225 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
|
4226 #else |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4227 GtkWidget *tree; |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4228 int _locked_by_me = FALSE; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4229 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4230 if(!handle) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4231 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4232 |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4233 DW_MUTEX_LOCK; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4234 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
|
4235 if(!tree || !GTK_IS_TREE(tree)) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4236 { |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4237 DW_MUTEX_UNLOCK; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4238 return; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4239 } |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4240 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
|
4241 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
|
4242 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
|
4243 #endif |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4244 } |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4245 |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4246 /* |
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
|
4247 * 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
|
4248 * 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
|
4249 * 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
|
4250 * 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
|
4251 */ |
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
|
4252 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
|
4253 { |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4254 #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
|
4255 GtkWidget *tree; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4256 GtkTreeStore *store; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4257 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
|
4258 |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4259 if(!handle) |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4260 return; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4261 |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4262 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
|
4263 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
|
4264 && 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
|
4265 (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
|
4266 { |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4267 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
|
4268 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
|
4269 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
|
4270 } |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4271 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
|
4272 #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
|
4273 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
|
4274 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4275 if(!handle || !item) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4276 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4277 |
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
|
4278 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
|
4279 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
|
4280 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
|
4281 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
|
4282 #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
|
4283 } |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
4284 |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
4285 /* |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
4286 * 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
|
4287 * 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
|
4288 * 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
|
4289 * 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
|
4290 */ |
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
|
4291 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
|
4292 { |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4293 #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
|
4294 GtkWidget *tree; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4295 GtkTreeStore *store; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4296 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
|
4297 |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4298 if(!handle) |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4299 return; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4300 |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4301 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
|
4302 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
|
4303 && 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
|
4304 (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
|
4305 { |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4306 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
|
4307 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
|
4308 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
|
4309 } |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4310 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
|
4311 #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
|
4312 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
|
4313 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4314 if(!handle || !item) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4315 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4316 |
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
|
4317 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
|
4318 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
|
4319 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
|
4320 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
|
4321 #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
|
4322 } |
c4e1139d9872
Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
52
diff
changeset
|
4323 |
c4e1139d9872
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 /* |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4325 * Removes a node from a tree. |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4326 * Parameters: |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4327 * 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
|
4328 * item: Handle to node to be deleted. |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4329 */ |
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
|
4330 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
|
4331 { |
138
d22b50184e3b
Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
135
diff
changeset
|
4332 #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
|
4333 GtkWidget *tree; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4334 GtkTreeStore *store; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4335 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
|
4336 |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4337 if(!handle) |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4338 return; |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4339 |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4340 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
|
4341 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
|
4342 && 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
|
4343 (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
|
4344 { |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4345 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
|
4346 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
|
4347 } |
ccf210251c99
Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
138
diff
changeset
|
4348 DW_MUTEX_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
|
4349 #else |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4350 GtkWidget *tree, *lastselect, *parenttree; |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4351 int _locked_by_me = FALSE; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4352 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4353 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
|
4354 return; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4355 |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4356 DW_MUTEX_LOCK; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4357 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
|
4358 if(!tree || !GTK_IS_TREE(tree)) |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4359 { |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4360 DW_MUTEX_UNLOCK; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4361 return; |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4362 } |
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 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4364 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
|
4365 |
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4366 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
|
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 if(lastselect == item) |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4369 { |
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
|
4370 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
|
4371 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
|
4372 } |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4373 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4374 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
|
4375 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
|
4376 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
|
4377 #endif |
30
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4378 } |
b1d7e8a28dfa
Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
22
diff
changeset
|
4379 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4380 static int _dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator, int extra) |
3 | 4381 { |
4382 GtkWidget *clist; | |
4383 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
|
4384 int z, multi; |
3 | 4385 int _locked_by_me = FALSE; |
355
3a71623fc219
Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
354
diff
changeset
|
4386 GtkJustification justification; |
3 | 4387 |
4388 DW_MUTEX_LOCK; | |
4389 clist = gtk_clist_new_with_titles(count, (gchar **)titles); | |
4390 if(!clist) | |
4391 { | |
4392 DW_MUTEX_UNLOCK; | |
4393 return FALSE; | |
4394 } | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4395 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
|
4396 gtk_object_set_data(GTK_OBJECT(handle), "_dw_multi", (gpointer)multi); |
3 | 4397 |
4398 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
|
4399 if(multi) |
2216e65ad2ae
Removed slider flags and container selection flags from the header file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
346
diff
changeset
|
4400 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
|
4401 else |
2216e65ad2ae
Removed slider flags and container selection flags from the header file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
346
diff
changeset
|
4402 gtk_clist_set_selection_mode(GTK_CLIST(clist), GTK_SELECTION_SINGLE); |
3 | 4403 gtk_container_add(GTK_CONTAINER(handle), clist); |
4404 gtk_object_set_user_data(GTK_OBJECT(handle), (gpointer)clist); | |
4405 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
|
4406 gtk_object_set_data(GTK_OBJECT(clist), "_dw_colcount", (gpointer)count); |
3 | 4407 |
4408 if(extra) | |
4409 gtk_clist_set_column_width(GTK_CLIST(clist), 1, 120); | |
4410 | |
4411 for(z=0;z<count;z++) | |
4412 { | |
4413 if(!extra || z > 1) | |
4414 gtk_clist_set_column_width(GTK_CLIST(clist), z, 50); | |
4415 sprintf(numbuf, "%d", z); | |
4416 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
|
4417 if(flags[z]&DW_CFA_RIGHT) |
3a71623fc219
Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
354
diff
changeset
|
4418 justification = GTK_JUSTIFY_RIGHT; |
3a71623fc219
Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
354
diff
changeset
|
4419 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
|
4420 justification = GTK_JUSTIFY_CENTER; |
3a71623fc219
Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
354
diff
changeset
|
4421 else |
3a71623fc219
Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
354
diff
changeset
|
4422 justification = GTK_JUSTIFY_LEFT; |
3a71623fc219
Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
354
diff
changeset
|
4423 gtk_clist_set_column_justification(GTK_CLIST(clist),z,justification); |
3 | 4424 } |
4425 | |
4426 DW_MUTEX_UNLOCK; | |
4427 return TRUE; | |
4428 } | |
4429 | |
4430 /* | |
4431 * Sets up the container columns. | |
4432 * Parameters: | |
4433 * handle: Handle to the container to be configured. | |
4434 * flags: An array of unsigned longs with column flags. | |
4435 * titles: An array of strings with column text titles. | |
4436 * count: The number of columns (this should match the arrays). | |
4437 * separator: The column number that contains the main separator. | |
4438 * (this item may only be used in OS/2) | |
4439 */ | |
4440 int dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator) | |
4441 { | |
4442 return _dw_container_setup(handle, flags, titles, count, separator, 0); | |
4443 } | |
4444 | |
4445 /* | |
4446 * Sets up the filesystem columns, note: filesystem always has an icon/filename field. | |
4447 * Parameters: | |
4448 * handle: Handle to the container to be configured. | |
4449 * flags: An array of unsigned longs with column flags. | |
4450 * titles: An array of strings with column text titles. | |
4451 * count: The number of columns (this should match the arrays). | |
4452 */ | |
4453 int dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count) | |
4454 { | |
4455 char **newtitles = malloc(sizeof(char *) * (count + 2)); | |
4456 unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 2)); | |
4457 | |
4458 newtitles[0] = "Icon"; | |
4459 newtitles[1] = "Filename"; | |
4460 | |
4461 newflags[0] = DW_CFA_BITMAPORICON | DW_CFA_CENTER | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR; | |
4462 newflags[1] = DW_CFA_STRING | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR; | |
4463 | |
4464 memcpy(&newtitles[2], titles, sizeof(char *) * count); | |
4465 memcpy(&newflags[2], flags, sizeof(unsigned long) * count); | |
4466 | |
4467 _dw_container_setup(handle, newflags, newtitles, count + 2, 2, 1); | |
4468 | |
4469 free(newtitles); | |
4470 free(newflags); | |
4471 return TRUE; | |
4472 } | |
4473 | |
4474 /* | |
4475 * Obtains an icon from a module (or header in GTK). | |
4476 * Parameters: | |
4477 * module: Handle to module (DLL) in OS/2 and Windows. | |
4478 * id: A unsigned long id int the resources on OS/2 and | |
4479 * Windows, on GTK this is converted to a pointer | |
4480 * to an embedded XPM. | |
4481 */ | |
4482 unsigned long dw_icon_load(unsigned long module, unsigned long id) | |
4483 { | |
4484 return id; | |
4485 } | |
4486 | |
4487 /* | |
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
|
4488 * 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
|
4489 * 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
|
4490 * 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
|
4491 * 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
|
4492 * (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
|
4493 */ |
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
|
4494 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
|
4495 { |
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
|
4496 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
|
4497 #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
|
4498 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
|
4499 #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
|
4500 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
|
4501 #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
|
4502 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
|
4503 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
|
4504 |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4505 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
|
4506 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
|
4507 |
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
|
4508 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
|
4509 |
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
|
4510 /* 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
|
4511 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
|
4512 { |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4513 /* 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
|
4514 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
|
4515 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
|
4516 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
|
4517 } |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4518 |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4519 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
|
4520 /* 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
|
4521 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
|
4522 { |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4523 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
|
4524 { |
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
|
4525 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
|
4526 break; |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4527 } |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4528 } |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4529 |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4530 /* 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
|
4531 * array. |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4532 */ |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4533 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
|
4534 { |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4535 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
|
4536 |
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
|
4537 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
|
4538 _PixmapCount++; |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4539 |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4540 _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
|
4541 |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4542 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
|
4543 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
|
4544 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
|
4545 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
|
4546 _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
|
4547 _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
|
4548 } |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4549 |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4550 #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
|
4551 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
|
4552 |
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
|
4553 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
|
4554 { |
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
|
4555 _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
|
4556 _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
|
4557 _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
|
4558 |
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
|
4559 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
|
4560 } |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4561 #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
|
4562 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
|
4563 |
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
|
4564 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
|
4565 { |
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
|
4566 _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
|
4567 _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
|
4568 |
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
|
4569 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
|
4570 _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
|
4571 _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
|
4572 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
|
4573 } |
258
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4574 #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
|
4575 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
|
4576 _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
|
4577 #endif |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4578 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
|
4579 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
|
4580 { |
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
|
4581 _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
|
4582 _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
|
4583 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
|
4584 } |
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
|
4585 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
|
4586 } |
9ea4ac9a097f
Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
256
diff
changeset
|
4587 |
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
|
4588 /* |
3 | 4589 * Frees a loaded resource in OS/2 and Windows. |
4590 * Parameters: | |
4591 * handle: Handle to icon returned by dw_icon_load(). | |
4592 */ | |
4593 void dw_icon_free(unsigned long handle) | |
4594 { | |
258
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 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
|
4596 * 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
|
4597 * 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
|
4598 */ |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4599 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
|
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 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
|
4602 |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4603 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
|
4604 { |
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
|
4605 #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
|
4606 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
|
4607 { |
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
|
4608 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
|
4609 _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
|
4610 } |
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
|
4611 #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
|
4612 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
|
4613 { |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4614 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
|
4615 _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
|
4616 } |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4617 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
|
4618 { |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4619 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
|
4620 _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
|
4621 } |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4622 _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
|
4623 } |
b2c436c84e5d
Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
257
diff
changeset
|
4624 } |
3 | 4625 } |
4626 | |
72
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
4627 /* 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
|
4628 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
|
4629 { |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
4630 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
|
4631 } |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
4632 |
3 | 4633 /* |
4634 * Allocates memory used to populate a container. | |
4635 * Parameters: | |
4636 * handle: Handle to the container window (widget). | |
4637 * rowcount: The number of items to be populated. | |
4638 */ | |
4639 void *dw_container_alloc(HWND handle, int rowcount) | |
4640 { | |
4641 int z, count = 0; | |
4642 GtkWidget *clist; | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
4643 GdkColor *fore, *back; |
3 | 4644 char **blah; |
4645 int _locked_by_me = FALSE; | |
4646 | |
4647 DW_MUTEX_LOCK; | |
4648 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
4649 if(!clist) | |
4650 { | |
4651 DW_MUTEX_UNLOCK; | |
4652 return NULL; | |
4653 } | |
4654 | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4655 count = (int)gtk_object_get_data(GTK_OBJECT(clist), "_dw_colcount"); |
3 | 4656 |
4657 if(!count) | |
4658 { | |
4659 DW_MUTEX_UNLOCK; | |
4660 return NULL; | |
4661 } | |
4662 | |
4663 blah = malloc(sizeof(char *) * count); | |
4664 memset(blah, 0, sizeof(char *) * count); | |
4665 | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4666 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
|
4667 back = (GdkColor *)gtk_object_get_data(GTK_OBJECT(clist), "_dw_backgdk"); |
3 | 4668 gtk_clist_freeze(GTK_CLIST(clist)); |
4669 for(z=0;z<rowcount;z++) | |
4670 { | |
4671 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
|
4672 if(fore) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
4673 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
|
4674 if(back) |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
4675 gtk_clist_set_background(GTK_CLIST(clist), z, back); |
3 | 4676 } |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4677 gtk_object_set_data(GTK_OBJECT(clist), "_dw_rowcount", (gpointer)rowcount); |
3 | 4678 free(blah); |
4679 DW_MUTEX_UNLOCK; | |
4680 return (void *)handle; | |
4681 } | |
4682 | |
4683 /* | |
4684 * Sets an item in specified row and column to the given data. | |
4685 * Parameters: | |
4686 * handle: Handle to the container window (widget). | |
4687 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
4688 * column: Zero based column of data being set. | |
4689 * row: Zero based row of data being set. | |
4690 * data: Pointer to the data to be added. | |
4691 */ | |
4692 void dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data) | |
4693 { | |
4694 char numbuf[10], textbuffer[100]; | |
4695 int flag = 0; | |
4696 GtkWidget *clist; | |
4697 int _locked_by_me = FALSE; | |
4698 | |
4699 DW_MUTEX_LOCK; | |
4700 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
4701 if(!clist) | |
4702 { | |
4703 DW_MUTEX_UNLOCK; | |
4704 return; | |
4705 } | |
4706 | |
4707 sprintf(numbuf, "%d", column); | |
4708 flag = (int)gtk_object_get_data(GTK_OBJECT(clist), numbuf); | |
4709 | |
4710 if(flag & DW_CFA_BITMAPORICON) | |
4711 { | |
4712 long hicon = *((long *)data); | |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
4713 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
|
4714 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
|
4715 |
3 | 4716 if(pixmap) |
4717 gtk_clist_set_pixmap(GTK_CLIST(clist), row, column, pixmap, bitmap); | |
4718 } | |
4719 else if(flag & DW_CFA_STRING) | |
4720 { | |
4721 char *tmp = *((char **)data); | |
4722 gtk_clist_set_text(GTK_CLIST(clist), row, column, tmp); | |
4723 } | |
4724 else if(flag & DW_CFA_ULONG) | |
4725 { | |
4726 ULONG tmp = *((ULONG *)data); | |
4727 | |
4728 sprintf(textbuffer, "%lu", tmp); | |
4729 | |
4730 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer); | |
4731 } | |
4732 else if(flag & DW_CFA_DATE) | |
4733 { | |
165
d03716228b7f
Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
164
diff
changeset
|
4734 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
|
4735 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
|
4736 |
d03716228b7f
Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
164
diff
changeset
|
4737 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
|
4738 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
|
4739 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
|
4740 |
d03716228b7f
Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
164
diff
changeset
|
4741 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
|
4742 |
3 | 4743 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer); |
4744 } | |
4745 else if(flag & DW_CFA_TIME) | |
4746 { | |
165
d03716228b7f
Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
164
diff
changeset
|
4747 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
|
4748 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
|
4749 |
d03716228b7f
Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
164
diff
changeset
|
4750 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
|
4751 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
|
4752 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
|
4753 |
d03716228b7f
Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
164
diff
changeset
|
4754 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
|
4755 |
3 | 4756 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer); |
4757 } | |
4758 DW_MUTEX_UNLOCK; | |
4759 } | |
4760 | |
4761 /* | |
167
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
4762 * 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
|
4763 * Parameters: |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
4764 * 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
|
4765 * 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
|
4766 * 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
|
4767 * 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
|
4768 */ |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
4769 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
|
4770 { |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
4771 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
|
4772 } |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
4773 |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
4774 /* |
3 | 4775 * Sets an item in specified row and column to the given data. |
4776 * Parameters: | |
4777 * handle: Handle to the container window (widget). | |
4778 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
4779 * column: Zero based column of data being set. | |
4780 * row: Zero based row of data being set. | |
4781 * data: Pointer to the data to be added. | |
4782 */ | |
4783 void dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, unsigned long icon) | |
4784 { | |
4785 dw_container_set_item(handle, pointer, 0, row, (void *)&icon); | |
4786 dw_container_set_item(handle, pointer, 1, row, (void *)&filename); | |
4787 } | |
4788 | |
4789 /* | |
4790 * Sets an item in specified row and column to the given data. | |
4791 * Parameters: | |
4792 * handle: Handle to the container window (widget). | |
4793 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
4794 * column: Zero based column of data being set. | |
4795 * row: Zero based row of data being set. | |
4796 * data: Pointer to the data to be added. | |
4797 */ | |
4798 void dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data) | |
4799 { | |
4800 dw_container_set_item(handle, pointer, column + 2, row, data); | |
4801 } | |
4802 | |
4803 /* | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4804 * 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
|
4805 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4806 * 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
|
4807 * 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
|
4808 * 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
|
4809 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4810 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
|
4811 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4812 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
|
4813 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
|
4814 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4815 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
|
4816 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
|
4817 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4818 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
|
4819 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
|
4820 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
|
4821 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4822 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4823 /* |
3 | 4824 * Sets the title of a row in the container. |
4825 * Parameters: | |
4826 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
4827 * row: Zero based row of data being set. | |
4828 * title: String title of the item. | |
4829 */ | |
4830 void dw_container_set_row_title(void *pointer, int row, char *title) | |
4831 { | |
4832 GtkWidget *clist; | |
4833 int _locked_by_me = FALSE; | |
4834 | |
4835 DW_MUTEX_LOCK; | |
4836 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(pointer)); | |
4837 | |
4838 if(clist) | |
4839 gtk_clist_set_row_data(GTK_CLIST(clist), row, (gpointer)title); | |
4840 DW_MUTEX_UNLOCK; | |
4841 } | |
4842 | |
4843 /* | |
4844 * Sets the title of a row in the container. | |
4845 * Parameters: | |
4846 * handle: Handle to the container window (widget). | |
4847 * pointer: Pointer to the allocated memory in dw_container_alloc(). | |
4848 * rowcount: The number of rows to be inserted. | |
4849 */ | |
4850 void dw_container_insert(HWND handle, void *pointer, int rowcount) | |
4851 { | |
4852 GtkWidget *clist; | |
4853 int _locked_by_me = FALSE; | |
4854 | |
4855 DW_MUTEX_LOCK; | |
4856 clist = gtk_object_get_user_data(GTK_OBJECT(handle)); | |
4857 | |
4858 if(clist && GTK_IS_CLIST(clist)) | |
4859 gtk_clist_thaw(GTK_CLIST(clist)); | |
4860 DW_MUTEX_UNLOCK; | |
4861 } | |
4862 | |
4863 /* | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4864 * 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
|
4865 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4866 * 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
|
4867 * 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
|
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 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
|
4870 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4871 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
|
4872 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
|
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 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
|
4875 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
|
4876 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
|
4877 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4878 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
|
4879 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4880 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
|
4881 |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
4882 _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
|
4883 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4884 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
|
4885 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
|
4886 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4887 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
|
4888 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
|
4889 else |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4890 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
|
4891 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4892 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
|
4893 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4894 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
|
4895 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4896 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4897 /* |
3 | 4898 * Removes all rows from a container. |
4899 * Parameters: | |
4900 * 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
|
4901 * redraw: TRUE to cause the container to redraw immediately. |
3 | 4902 */ |
52
0804483f6320
Added a redraw parameter to dw_container_clear().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
51
diff
changeset
|
4903 void dw_container_clear(HWND handle, int redraw) |
3 | 4904 { |
4905 GtkWidget *clist; | |
4906 int _locked_by_me = FALSE; | |
4907 | |
4908 DW_MUTEX_LOCK; | |
4909 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
4910 if(clist && GTK_IS_CLIST(clist)) | |
4911 { | |
72
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
4912 _dw_unselect(clist); |
3 | 4913 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
|
4914 gtk_object_set_data(GTK_OBJECT(clist), "_dw_rowcount", (gpointer)0); |
3 | 4915 } |
4916 DW_MUTEX_UNLOCK; | |
4917 } | |
4918 | |
4919 /* | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4920 * 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
|
4921 * Parameters: |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4922 * 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
|
4923 * 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
|
4924 * 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
|
4925 * 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
|
4926 */ |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4927 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
|
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 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
|
4930 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
|
4931 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
|
4932 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4933 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
|
4934 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
|
4935 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
|
4936 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4937 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
|
4938 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
|
4939 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4940 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
|
4941 { |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4942 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
|
4943 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
|
4944 break; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4945 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
|
4946 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
|
4947 break; |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4948 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4949 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
|
4950 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4951 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4952 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
|
4953 } |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4954 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
4955 /* |
3 | 4956 * Starts a new query of a container. |
4957 * Parameters: | |
4958 * handle: Handle to the window (widget) to be queried. | |
4959 * flags: If this parameter is DW_CRA_SELECTED it will only | |
4960 * return items that are currently selected. Otherwise | |
4961 * it will return all records in the container. | |
4962 */ | |
4963 char *dw_container_query_start(HWND handle, unsigned long flags) | |
4964 { | |
4965 GtkWidget *clist; | |
4966 GList *list; | |
4967 char *retval = NULL; | |
4968 int _locked_by_me = FALSE; | |
4969 | |
4970 DW_MUTEX_LOCK; | |
4971 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
4972 | |
4973 if(!clist) | |
4974 { | |
4975 DW_MUTEX_UNLOCK; | |
4976 return NULL; | |
4977 } | |
4978 | |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4979 /* 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
|
4980 if(flags & DW_CRA_SELECTED) |
3 | 4981 { |
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
|
4982 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
|
4983 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4984 if(list) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4985 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
4986 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
|
4987 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
|
4988 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4989 } |
364
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
4990 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
|
4991 { |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
4992 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
|
4993 } |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4994 else |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4995 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
4996 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
|
4997 gtk_object_set_data(GTK_OBJECT(clist), "_dw_querypos", (gpointer)1); |
3 | 4998 } |
4999 DW_MUTEX_UNLOCK; | |
5000 return retval; | |
5001 } | |
5002 | |
5003 /* | |
5004 * Continues an existing query of a container. | |
5005 * Parameters: | |
5006 * handle: Handle to the window (widget) to be queried. | |
5007 * flags: If this parameter is DW_CRA_SELECTED it will only | |
5008 * return items that are currently selected. Otherwise | |
5009 * it will return all records in the container. | |
5010 */ | |
5011 char *dw_container_query_next(HWND handle, unsigned long flags) | |
5012 { | |
5013 GtkWidget *clist; | |
5014 GList *list; | |
5015 char *retval = NULL; | |
5016 int _locked_by_me = FALSE; | |
5017 | |
5018 DW_MUTEX_LOCK; | |
5019 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
5020 | |
5021 if(!clist) | |
5022 { | |
5023 DW_MUTEX_UNLOCK; | |
5024 return NULL; | |
5025 } | |
5026 | |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5027 /* 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
|
5028 if(flags & DW_CRA_SELECTED) |
3 | 5029 { |
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
|
5030 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
|
5031 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5032 if(list) |
3 | 5033 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5034 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
|
5035 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
|
5036 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5037 while(list && counter < pos) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5038 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5039 list = list->next; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5040 counter++; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5041 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5042 |
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
|
5043 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
|
5044 retval = (char *)gtk_clist_get_row_data(GTK_CLIST(clist), GPOINTER_TO_UINT(list->data)); |
3 | 5045 } |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5046 } |
364
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
5047 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
|
5048 { |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
5049 /* 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
|
5050 * 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
|
5051 */ |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
5052 retval = NULL; |
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
5053 } |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5054 else |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5055 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5056 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
|
5057 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5058 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
|
5059 gtk_object_set_data(GTK_OBJECT(clist), "_dw_querypos", (gpointer)pos+1); |
3 | 5060 } |
5061 DW_MUTEX_UNLOCK; | |
5062 return retval; | |
5063 } | |
5064 | |
5065 /* | |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5066 * 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
|
5067 * Parameters: |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5068 * 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
|
5069 * 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
|
5070 */ |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5071 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
|
5072 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5073 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
|
5074 GtkWidget *clist; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5075 int rowcount, z; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5076 char *rowdata; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5077 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5078 DW_MUTEX_LOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5079 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
|
5080 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5081 if(!clist) |
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 DW_MUTEX_UNLOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5084 return; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5085 } |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5086 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
|
5087 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5088 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
|
5089 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5090 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
|
5091 if(rowdata == text) |
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 gfloat pos; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5094 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
|
5095 |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
5096 _dw_unselect(clist); |
ab77a22a2a36
Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
69
diff
changeset
|
5097 |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5098 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
|
5099 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5100 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
|
5101 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
|
5102 DW_MUTEX_UNLOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5103 return; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5104 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5105 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5106 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5107 DW_MUTEX_UNLOCK; |
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 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5110 /* |
167
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5111 * 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
|
5112 * Parameters: |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5113 * 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
|
5114 * 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
|
5115 */ |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5116 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
|
5117 { |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5118 int _locked_by_me = FALSE; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5119 GtkWidget *clist; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5120 int rowcount, z; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5121 char *rowdata; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5122 |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5123 DW_MUTEX_LOCK; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5124 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
|
5125 |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5126 if(!clist) |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5127 { |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5128 DW_MUTEX_UNLOCK; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5129 return; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5130 } |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5131 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
|
5132 |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5133 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
|
5134 { |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5135 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
|
5136 if(rowdata == text) |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5137 { |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5138 _dw_unselect(clist); |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5139 |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5140 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
|
5141 |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5142 rowcount--; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5143 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5144 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
|
5145 DW_MUTEX_UNLOCK; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5146 return; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5147 } |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5148 } |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5149 |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5150 DW_MUTEX_UNLOCK; |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5151 } |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5152 |
0b3debaa9c6c
Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
165
diff
changeset
|
5153 /* |
69
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5154 * 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
|
5155 * Parameters: |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5156 * 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
|
5157 */ |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5158 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
|
5159 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5160 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
|
5161 GtkWidget *clist; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5162 int colcount, z; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5163 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5164 DW_MUTEX_LOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5165 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
|
5166 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5167 if(!clist) |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5168 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5169 DW_MUTEX_UNLOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5170 return; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5171 } |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5172 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
|
5173 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
|
5174 { |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5175 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
|
5176 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
|
5177 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5178 DW_MUTEX_UNLOCK; |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5179 } |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5180 |
9510897c0b03
Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
67
diff
changeset
|
5181 /* |
3 | 5182 * Creates a rendering context widget (window) to be packed. |
5183 * Parameters: | |
5184 * id: An id to be used with dw_window_from_id. | |
5185 * Returns: | |
5186 * A handle to the widget or NULL on failure. | |
5187 */ | |
5188 HWND dw_render_new(unsigned long id) | |
5189 { | |
5190 int _locked_by_me = FALSE; | |
5191 GtkWidget *tmp; | |
5192 | |
5193 DW_MUTEX_LOCK; | |
5194 tmp = gtk_drawing_area_new(); | |
5195 gtk_widget_set_events(tmp, GDK_EXPOSURE_MASK | |
5196 | GDK_LEAVE_NOTIFY_MASK | |
5197 | 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
|
5198 | GDK_KEY_PRESS_MASK |
3 | 5199 | GDK_POINTER_MOTION_MASK |
5200 | 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
|
5201 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
|
5202 GTK_WIDGET_SET_FLAGS(tmp, GTK_CAN_FOCUS); |
3 | 5203 gtk_widget_show(tmp); |
5204 DW_MUTEX_UNLOCK; | |
5205 return tmp; | |
5206 } | |
5207 | |
193
efd4703450fa
Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
185
diff
changeset
|
5208 /* 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
|
5209 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
|
5210 { |
efd4703450fa
Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
185
diff
changeset
|
5211 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
|
5212 { |
efd4703450fa
Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
185
diff
changeset
|
5213 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
|
5214 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
|
5215 } |
372
3ef2cf70ee07
Code for drawing text with a background color on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
369
diff
changeset
|
5216 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
|
5217 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
|
5218 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
|
5219 } |
efd4703450fa
Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
185
diff
changeset
|
5220 |
3 | 5221 /* Sets the current foreground drawing color. |
5222 * Parameters: | |
5223 * red: red value. | |
5224 * green: green value. | |
5225 * blue: blue value. | |
5226 */ | |
5227 void dw_color_foreground_set(unsigned long value) | |
5228 { | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5229 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
|
5230 GdkColor color = _internal_color(value); |
3 | 5231 |
5232 DW_MUTEX_LOCK; | |
373
d04b0699fc28
Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
372
diff
changeset
|
5233 gdk_color_alloc(_dw_cmap, &color); |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5234 _foreground[index] = color; |
3 | 5235 DW_MUTEX_UNLOCK; |
5236 } | |
5237 | |
5238 /* Sets the current background drawing color. | |
5239 * Parameters: | |
5240 * red: red value. | |
5241 * green: green value. | |
5242 * blue: blue value. | |
5243 */ | |
5244 void dw_color_background_set(unsigned long value) | |
5245 { | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5246 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
|
5247 GdkColor color = _internal_color(value); |
3 | 5248 |
5249 DW_MUTEX_LOCK; | |
373
d04b0699fc28
Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
372
diff
changeset
|
5250 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
|
5251 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
|
5252 _transparent[index] = 1; |
d04b0699fc28
Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
372
diff
changeset
|
5253 else |
d04b0699fc28
Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
372
diff
changeset
|
5254 _transparent[index] = 0; |
d04b0699fc28
Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
372
diff
changeset
|
5255 |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5256 _background[index] = color; |
3 | 5257 DW_MUTEX_UNLOCK; |
5258 } | |
5259 | |
5260 GdkGC *_set_colors(GdkWindow *window) | |
5261 { | |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5262 GdkGC *gc = NULL; |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5263 int index = _find_thread_index(dw_thread_id()); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5264 |
3 | 5265 if(!window) |
5266 return NULL; | |
5267 gc = gdk_gc_new(window); | |
5268 if(gc) | |
5269 { | |
373
d04b0699fc28
Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
372
diff
changeset
|
5270 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
|
5271 gdk_gc_set_background(gc, &_background[index]); |
d04b0699fc28
Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
372
diff
changeset
|
5272 gdk_gc_set_colormap(gc, _dw_cmap); |
3 | 5273 } |
5274 return gc; | |
5275 } | |
5276 | |
5277 /* Draw a point on a window (preferably a render window). | |
5278 * Parameters: | |
5279 * handle: Handle to the window. | |
5280 * pixmap: Handle to the pixmap. (choose only one of these) | |
5281 * x: X coordinate. | |
5282 * y: Y coordinate. | |
5283 */ | |
5284 void dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y) | |
5285 { | |
5286 int _locked_by_me = FALSE; | |
5287 GdkGC *gc = NULL; | |
5288 | |
5289 DW_MUTEX_LOCK; | |
5290 if(handle) | |
5291 gc = _set_colors(handle->window); | |
5292 else if(pixmap) | |
5293 gc = _set_colors(pixmap->pixmap); | |
5294 if(gc) | |
5295 { | |
5296 gdk_draw_point(handle ? handle->window : pixmap->pixmap, gc, x, y); | |
5297 gdk_gc_unref(gc); | |
5298 } | |
5299 DW_MUTEX_UNLOCK; | |
5300 } | |
5301 | |
5302 /* Draw a line on a window (preferably a render window). | |
5303 * Parameters: | |
5304 * handle: Handle to the window. | |
5305 * pixmap: Handle to the pixmap. (choose only one of these) | |
5306 * x1: First X coordinate. | |
5307 * y1: First Y coordinate. | |
5308 * x2: Second X coordinate. | |
5309 * y2: Second Y coordinate. | |
5310 */ | |
5311 void dw_draw_line(HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2) | |
5312 { | |
5313 int _locked_by_me = FALSE; | |
5314 GdkGC *gc = NULL; | |
5315 | |
5316 DW_MUTEX_LOCK; | |
5317 if(handle) | |
5318 gc = _set_colors(handle->window); | |
5319 else if(pixmap) | |
5320 gc = _set_colors(pixmap->pixmap); | |
5321 if(gc) | |
5322 { | |
5323 gdk_draw_line(handle ? handle->window : pixmap->pixmap, gc, x1, y1, x2, y2); | |
5324 gdk_gc_unref(gc); | |
5325 } | |
5326 DW_MUTEX_UNLOCK; | |
5327 } | |
5328 | |
5329 /* Draw a rectangle on a window (preferably a render window). | |
5330 * Parameters: | |
5331 * handle: Handle to the window. | |
5332 * pixmap: Handle to the pixmap. (choose only one of these) | |
5333 * x: X coordinate. | |
5334 * y: Y coordinate. | |
5335 * width: Width of rectangle. | |
5336 * height: Height of rectangle. | |
5337 */ | |
5338 void dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height) | |
5339 { | |
5340 int _locked_by_me = FALSE; | |
5341 GdkGC *gc = NULL; | |
5342 | |
5343 DW_MUTEX_LOCK; | |
5344 if(handle) | |
5345 gc = _set_colors(handle->window); | |
5346 else if(pixmap) | |
5347 gc = _set_colors(pixmap->pixmap); | |
5348 if(gc) | |
5349 { | |
5350 gdk_draw_rectangle(handle ? handle->window : pixmap->pixmap, gc, fill, x, y, width, height); | |
5351 gdk_gc_unref(gc); | |
5352 } | |
5353 DW_MUTEX_UNLOCK; | |
5354 } | |
5355 | |
5356 /* Draw text on a window (preferably a render window). | |
5357 * Parameters: | |
5358 * handle: Handle to the window. | |
5359 * pixmap: Handle to the pixmap. (choose only one of these) | |
5360 * x: X coordinate. | |
5361 * y: Y coordinate. | |
5362 * text: Text to be displayed. | |
5363 */ | |
5364 void dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text) | |
5365 { | |
5366 int _locked_by_me = FALSE; | |
5367 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
|
5368 #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
|
5369 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
|
5370 #else |
3 | 5371 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
|
5372 #endif |
3 | 5373 char *fontname = "fixed"; |
5374 | |
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
|
5375 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
|
5376 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
|
5377 |
3 | 5378 DW_MUTEX_LOCK; |
5379 if(handle) | |
5380 { | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5381 fontname = (char *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_fontname"); |
3 | 5382 gc = _set_colors(handle->window); |
5383 } | |
5384 else if(pixmap) | |
5385 { | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
5386 fontname = (char *)gtk_object_get_data(GTK_OBJECT(pixmap->handle), "_dw_fontname"); |
3 | 5387 gc = _set_colors(pixmap->pixmap); |
5388 } | |
5389 if(gc) | |
5390 { | |
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
|
5391 #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
|
5392 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
|
5393 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
|
5394 { |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5395 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
|
5396 |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5397 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
|
5398 { |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5399 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
|
5400 |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5401 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
|
5402 { |
372
3ef2cf70ee07
Code for drawing text with a background color on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
369
diff
changeset
|
5403 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
|
5404 |
373
d04b0699fc28
Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
372
diff
changeset
|
5405 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
|
5406 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
|
5407 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
|
5408 |
373
d04b0699fc28
Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
372
diff
changeset
|
5409 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
|
5410 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
|
5411 else |
3ef2cf70ee07
Code for drawing text with a background color on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
369
diff
changeset
|
5412 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
|
5413 |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5414 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
|
5415 } |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5416 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
|
5417 } |
b479002e013f
Upped the 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 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
|
5419 } |
b479002e013f
Upped the 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 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
|
5422 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
|
5423 font = gdk_font_load("fixed"); |
3 | 5424 if(font) |
5425 { | |
5426 gint ascent; | |
5427 | |
5428 gdk_text_extents(font, text, strlen(text), NULL, NULL, NULL, &ascent, NULL); | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
5429 gdk_draw_text(handle ? handle->window : pixmap->pixmap, font, gc, x, y + ascent + 2, text, strlen(text)); |
3 | 5430 gdk_font_unref(font); |
5431 } | |
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
|
5432 #endif |
149
6028f787f7c8
Fixed a graphics context leak in dw_draw_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
148
diff
changeset
|
5433 gdk_gc_unref(gc); |
3 | 5434 } |
5435 DW_MUTEX_UNLOCK; | |
5436 } | |
5437 | |
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
|
5438 /* 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
|
5439 * 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
|
5440 * 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
|
5441 * 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
|
5442 * 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
|
5443 * 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
|
5444 * 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
|
5445 */ |
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
|
5446 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
|
5447 { |
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
|
5448 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
|
5449 #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
|
5450 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
|
5451 #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
|
5452 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
|
5453 #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
|
5454 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
|
5455 |
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
|
5456 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
|
5457 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
|
5458 |
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
|
5459 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
|
5460 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
|
5461 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
|
5462 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
|
5463 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
|
5464 |
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
|
5465 #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
|
5466 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
|
5467 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
|
5468 { |
b479002e013f
Upped the 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 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
|
5470 |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5471 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
|
5472 { |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5473 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
|
5474 |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5475 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
|
5476 { |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5477 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
|
5478 |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5479 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
|
5480 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
|
5481 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
|
5482 |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5483 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
|
5484 *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
|
5485 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
|
5486 *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
|
5487 |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5488 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
|
5489 } |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5490 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
|
5491 } |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5492 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
|
5493 } |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
5494 #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
|
5495 |
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
|
5496 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
|
5497 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
|
5498 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
|
5499 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
|
5500 { |
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
|
5501 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
|
5502 *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
|
5503 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
|
5504 *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
|
5505 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
|
5506 } |
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
|
5507 #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
|
5508 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
|
5509 } |
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 |
3 | 5511 /* |
5512 * Creates a pixmap with given parameters. | |
5513 * Parameters: | |
5514 * handle: Window handle the pixmap is associated with. | |
5515 * width: Width of the pixmap in pixels. | |
5516 * height: Height of the pixmap in pixels. | |
5517 * depth: Color depth of the pixmap. | |
5518 * Returns: | |
5519 * A handle to a pixmap or NULL on failure. | |
5520 */ | |
5521 HPIXMAP dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth) | |
5522 { | |
5523 int _locked_by_me = FALSE; | |
5524 HPIXMAP pixmap; | |
5525 | |
5526 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) | |
5527 return NULL; | |
5528 | |
5529 if (!depth) | |
66
664a274a46a6
Fixed color depth problem when creating a new pixmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
63
diff
changeset
|
5530 depth = -1; |
3 | 5531 |
5532 pixmap->width = width; pixmap->height = height; | |
5533 | |
5534 | |
5535 DW_MUTEX_LOCK; | |
5536 pixmap->handle = handle; | |
5537 pixmap->pixmap = gdk_pixmap_new(handle->window, width, height, depth); | |
5538 DW_MUTEX_UNLOCK; | |
5539 return pixmap; | |
5540 } | |
5541 | |
5542 /* | |
241
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5543 * Creates a pixmap from a file. |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5544 * Parameters: |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5545 * 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
|
5546 * 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
|
5547 * DW pick the appropriate file extension. |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5548 * (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
|
5549 * Returns: |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5550 * 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
|
5551 */ |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5552 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
|
5553 { |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5554 int _locked_by_me = FALSE; |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5555 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
|
5556 #ifndef USE_IMLIB |
241
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5557 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
|
5558 #endif |
241
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5559 #if GTK_MAJOR_VERSION > 1 |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5560 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
|
5561 #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
|
5562 GdkImlibImage *image; |
241
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5563 #endif |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5564 char *file = alloca(strlen(filename) + 5); |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5565 |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5566 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
|
5567 return NULL; |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5568 |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5569 strcpy(file, filename); |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5570 |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5571 /* 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
|
5572 if(access(file, 04) != 0) |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5573 { |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5574 /* Try with .xpm extention */ |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5575 strcat(file, ".xpm"); |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5576 if(access(file, 04) != 0) |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5577 { |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5578 free(pixmap); |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5579 return NULL; |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5580 } |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5581 } |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5582 |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5583 DW_MUTEX_LOCK; |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5584 #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
|
5585 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
|
5586 |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5587 pixmap->width = gdk_pixbuf_get_width(pixbuf); |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5588 pixmap->height = gdk_pixbuf_get_height(pixbuf); |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5589 |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5590 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
|
5591 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
|
5592 #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
|
5593 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
|
5594 |
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
|
5595 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
|
5596 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
|
5597 |
245
11baf43efbc2
Must call gdk_imlib_render() before gdk_imlib_copy_image().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
244
diff
changeset
|
5598 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
|
5599 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
|
5600 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
|
5601 #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
|
5602 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
|
5603 #endif |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5604 pixmap->handle = handle; |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5605 DW_MUTEX_UNLOCK; |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5606 return pixmap; |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5607 } |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5608 |
00d2b1bcf036
Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
239
diff
changeset
|
5609 /* |
3 | 5610 * Creates a pixmap from internal resource graphic specified by id. |
5611 * Parameters: | |
5612 * handle: Window handle the pixmap is associated with. | |
5613 * id: Resource ID associated with requested pixmap. | |
5614 * Returns: | |
5615 * A handle to a pixmap or NULL on failure. | |
5616 */ | |
5617 HPIXMAP dw_pixmap_grab(HWND handle, ULONG id) | |
5618 { | |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
5619 GdkBitmap *bitmap = NULL; |
3 | 5620 HPIXMAP pixmap; |
5621 int _locked_by_me = FALSE; | |
5622 | |
5623 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) | |
5624 return NULL; | |
5625 | |
5626 | |
5627 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
|
5628 pixmap->pixmap = _find_pixmap(&bitmap, id, handle, &pixmap->width, &pixmap->height); |
3 | 5629 if(pixmap->pixmap) |
5630 { | |
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
|
5631 #if GTK_MAJOR_VERSION < 2 |
3 | 5632 GdkPixmapPrivate *pvt = (GdkPixmapPrivate *)pixmap->pixmap; |
5633 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
|
5634 #endif |
3 | 5635 } |
5636 DW_MUTEX_UNLOCK; | |
5637 return pixmap; | |
5638 } | |
5639 | |
5640 /* Call this after drawing to the screen to make sure | |
5641 * anything you have drawn is visible. | |
5642 */ | |
5643 void dw_flush(void) | |
5644 { | |
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
|
5645 #if GTK_MAJOR_VERSION < 2 |
3 | 5646 int _locked_by_me = FALSE; |
5647 | |
5648 DW_MUTEX_LOCK; | |
5649 gdk_flush(); | |
5650 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
|
5651 #endif |
3 | 5652 } |
5653 | |
5654 /* | |
5655 * Destroys an allocated pixmap. | |
5656 * Parameters: | |
5657 * pixmap: Handle to a pixmap returned by | |
5658 * dw_pixmap_new.. | |
5659 */ | |
5660 void dw_pixmap_destroy(HPIXMAP pixmap) | |
5661 { | |
5662 int _locked_by_me = FALSE; | |
5663 | |
5664 DW_MUTEX_LOCK; | |
5665 gdk_pixmap_unref(pixmap->pixmap); | |
5666 free(pixmap); | |
5667 DW_MUTEX_UNLOCK; | |
5668 } | |
5669 | |
5670 /* | |
5671 * Copies from one item to another. | |
5672 * Parameters: | |
5673 * dest: Destination window handle. | |
5674 * destp: Destination pixmap. (choose only one). | |
5675 * xdest: X coordinate of destination. | |
5676 * ydest: Y coordinate of destination. | |
5677 * width: Width of area to copy. | |
5678 * height: Height of area to copy. | |
5679 * src: Source window handle. | |
5680 * srcp: Source pixmap. (choose only one). | |
5681 * xsrc: X coordinate of source. | |
5682 * ysrc: Y coordinate of source. | |
5683 */ | |
5684 void dw_pixmap_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc) | |
5685 { | |
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
|
5686 /* 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
|
5687 * 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
|
5688 * 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
|
5689 * 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
|
5690 */ |
3 | 5691 int _locked_by_me = FALSE; |
5692 GdkGC *gc = NULL; | |
5693 | |
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
|
5694 if((!dest && (!destp || !destp->pixmap)) || (!src && (!srcp || !srcp->pixmap))) |
3 | 5695 return; |
5696 | |
5697 DW_MUTEX_LOCK; | |
5698 if(dest) | |
5699 gc = _set_colors(dest->window); | |
5700 else if(src) | |
5701 gc = _set_colors(src->window); | |
5702 else if(destp) | |
5703 gc = gdk_gc_new(destp->pixmap); | |
5704 else if(srcp) | |
5705 gc = gdk_gc_new(srcp->pixmap); | |
122
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
5706 |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
5707 if(gc) |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
5708 { |
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
5709 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
|
5710 gdk_gc_unref(gc); |
3 | 5711 } |
5712 DW_MUTEX_UNLOCK; | |
5713 } | |
5714 | |
5715 /* | |
5716 * Emits a beep. | |
5717 * Parameters: | |
5718 * freq: Frequency. | |
5719 * dur: Duration. | |
5720 */ | |
5721 void dw_beep(int freq, int dur) | |
5722 { | |
5723 int _locked_by_me = FALSE; | |
5724 | |
5725 DW_MUTEX_LOCK; | |
5726 gdk_beep(); | |
5727 DW_MUTEX_UNLOCK; | |
5728 } | |
5729 | |
157
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5730 void _my_strlwr(char *buf) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5731 { |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5732 int z, len = strlen(buf); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5733 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5734 for(z=0;z<len;z++) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5735 { |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5736 if(buf[z] >= 'A' && buf[z] <= 'Z') |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5737 buf[z] -= 'A' - 'a'; |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5738 } |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5739 } |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5740 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5741 /* Open a shared library and return a handle. |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5742 * Parameters: |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5743 * name: Base name of the shared library. |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5744 * handle: Pointer to a module handle, |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5745 * will be filled in with the handle. |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5746 */ |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5747 int dw_module_load(char *name, HMOD *handle) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5748 { |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5749 int len; |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5750 char *newname; |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5751 char errorbuf[1024]; |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5752 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5753 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5754 if(!handle) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5755 return -1; |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5756 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5757 if((len = strlen(name)) == 0) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5758 return -1; |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5759 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5760 /* Lenth + "lib" + ".so" + NULL */ |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5761 newname = malloc(len + 7); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5762 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5763 if(!newname) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5764 return -1; |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5765 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5766 sprintf(newname, "lib%s.so", name); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5767 _my_strlwr(newname); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5768 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5769 *handle = dlopen(newname, RTLD_NOW); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5770 if(*handle == NULL) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5771 { |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5772 strncpy(errorbuf, dlerror(), 1024); |
164
d35771f70bdd
Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
163
diff
changeset
|
5773 printf("%s\n", errorbuf); |
157
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5774 sprintf(newname, "lib%s.so", name); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5775 *handle = dlopen(newname, RTLD_NOW); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5776 } |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5777 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5778 free(newname); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5779 |
163
0322836c5299
Return -1 on error from dw_module_load().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
162
diff
changeset
|
5780 return (NULL == *handle) ? -1 : 0; |
157
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5781 } |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5782 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5783 /* Queries the address of a symbol within open handle. |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5784 * Parameters: |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5785 * handle: Module handle returned by dw_module_load() |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5786 * name: Name of the symbol you want the address of. |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5787 * func: A pointer to a function pointer, to obtain |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5788 * the address. |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5789 */ |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5790 int dw_module_symbol(HMOD handle, char *name, void**func) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5791 { |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5792 if(!func || !name) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5793 return -1; |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5794 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5795 if(strlen(name) == 0) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5796 return -1; |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5797 |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5798 *func = (void*)dlsym(handle, name); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5799 return (NULL == *func); |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5800 } |
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 /* Frees the shared library previously opened. |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5803 * Parameters: |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5804 * handle: Module handle returned by dw_module_load() |
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 int dw_module_close(HMOD handle) |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5807 { |
162
df59a3fc6de6
Fixed a minor bug in dw_module_close().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
157
diff
changeset
|
5808 if(handle) |
df59a3fc6de6
Fixed a minor bug in dw_module_close().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
157
diff
changeset
|
5809 return dlclose(handle); |
df59a3fc6de6
Fixed a minor bug in dw_module_close().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
157
diff
changeset
|
5810 return 0; |
157
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5811 } |
a07dd2e819f3
Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
155
diff
changeset
|
5812 |
3 | 5813 /* |
5814 * Returns the handle to an unnamed mutex semaphore. | |
5815 */ | |
5816 HMTX dw_mutex_new(void) | |
5817 { | |
239
403b07f873e1
Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
237
diff
changeset
|
5818 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
|
5819 |
403b07f873e1
Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
237
diff
changeset
|
5820 pthread_mutex_init(mutex, NULL); |
3 | 5821 return mutex; |
5822 } | |
5823 | |
5824 /* | |
5825 * Closes a semaphore created by dw_mutex_new(). | |
5826 * Parameters: | |
5827 * mutex: The handle to the mutex returned by dw_mutex_new(). | |
5828 */ | |
5829 void dw_mutex_close(HMTX mutex) | |
5830 { | |
239
403b07f873e1
Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
237
diff
changeset
|
5831 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
|
5832 { |
403b07f873e1
Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
237
diff
changeset
|
5833 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
|
5834 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
|
5835 } |
3 | 5836 } |
5837 | |
5838 /* | |
5839 * Tries to gain access to the semaphore, if it can't it blocks. | |
5840 * Parameters: | |
5841 * mutex: The handle to the mutex returned by dw_mutex_new(). | |
5842 */ | |
5843 void dw_mutex_lock(HMTX mutex) | |
5844 { | |
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
|
5845 /* 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
|
5846 * 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
|
5847 */ |
baaf4b04d284
Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
94
diff
changeset
|
5848 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
|
5849 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
|
5850 |
239
403b07f873e1
Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
237
diff
changeset
|
5851 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
|
5852 |
baaf4b04d284
Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
94
diff
changeset
|
5853 /* 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
|
5854 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
|
5855 gdk_threads_enter(); |
3 | 5856 } |
5857 | |
5858 /* | |
5859 * Reliquishes the access to the semaphore. | |
5860 * Parameters: | |
5861 * mutex: The handle to the mutex returned by dw_mutex_new(). | |
5862 */ | |
5863 void dw_mutex_unlock(HMTX mutex) | |
5864 { | |
239
403b07f873e1
Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
237
diff
changeset
|
5865 pthread_mutex_unlock(mutex); |
3 | 5866 } |
5867 | |
5868 /* | |
5869 * Returns the handle to an unnamed event semaphore. | |
5870 */ | |
5871 HEV dw_event_new(void) | |
5872 { | |
5873 HEV eve = (HEV)malloc(sizeof(struct _dw_unix_event)); | |
5874 | |
5875 if(!eve) | |
5876 return NULL; | |
5877 | |
5878 /* We need to be careful here, mutexes on Linux are | |
5879 * FAST by default but are error checking on other | |
5880 * systems such as FreeBSD and OS/2, perhaps others. | |
5881 */ | |
5882 pthread_mutex_init (&(eve->mutex), NULL); | |
5883 pthread_mutex_lock (&(eve->mutex)); | |
5884 pthread_cond_init (&(eve->event), NULL); | |
5885 | |
5886 pthread_mutex_unlock (&(eve->mutex)); | |
5887 eve->alive = 1; | |
5888 eve->posted = 0; | |
5889 | |
5890 return eve; | |
5891 } | |
5892 | |
5893 /* | |
5894 * Resets a semaphore created by dw_event_new(). | |
5895 * Parameters: | |
5896 * eve: The handle to the event returned by dw_event_new(). | |
5897 */ | |
5898 int dw_event_reset (HEV eve) | |
5899 { | |
5900 if(!eve) | |
5901 return FALSE; | |
5902 | |
5903 pthread_mutex_lock (&(eve->mutex)); | |
5904 pthread_cond_broadcast (&(eve->event)); | |
5905 pthread_cond_init (&(eve->event), NULL); | |
5906 eve->posted = 0; | |
5907 pthread_mutex_unlock (&(eve->mutex)); | |
5908 return 0; | |
5909 } | |
5910 | |
5911 /* | |
5912 * Posts a semaphore created by dw_event_new(). Causing all threads | |
5913 * waiting on this event in dw_event_wait to continue. | |
5914 * Parameters: | |
5915 * eve: The handle to the event returned by dw_event_new(). | |
5916 */ | |
5917 int dw_event_post (HEV eve) | |
5918 { | |
5919 if(!eve) | |
5920 return FALSE; | |
5921 | |
5922 pthread_mutex_lock (&(eve->mutex)); | |
5923 pthread_cond_broadcast (&(eve->event)); | |
5924 eve->posted = 1; | |
5925 pthread_mutex_unlock (&(eve->mutex)); | |
5926 return 0; | |
5927 } | |
5928 | |
5929 /* | |
5930 * Waits on a semaphore created by dw_event_new(), until the | |
5931 * event gets posted or until the timeout expires. | |
5932 * Parameters: | |
5933 * eve: The handle to the event returned by dw_event_new(). | |
5934 */ | |
5935 int dw_event_wait(HEV eve, unsigned long timeout) | |
5936 { | |
5937 int rc; | |
5938 struct timeval now; | |
5939 struct timespec timeo; | |
5940 | |
5941 if(!eve) | |
5942 return FALSE; | |
5943 | |
5944 if(eve->posted) | |
5945 return 0; | |
5946 | |
5947 pthread_mutex_lock (&(eve->mutex)); | |
5948 gettimeofday(&now, 0); | |
5949 timeo.tv_sec = now.tv_sec + (timeout / 1000); | |
5950 timeo.tv_nsec = now.tv_usec * 1000; | |
5951 rc = pthread_cond_timedwait (&(eve->event), &(eve->mutex), &timeo); | |
5952 pthread_mutex_unlock (&(eve->mutex)); | |
5953 if(!rc) | |
5954 return 1; | |
5955 if(rc == ETIMEDOUT) | |
5956 return -1; | |
5957 return 0; | |
5958 } | |
5959 | |
5960 /* | |
5961 * Closes a semaphore created by dw_event_new(). | |
5962 * Parameters: | |
5963 * eve: The handle to the event returned by dw_event_new(). | |
5964 */ | |
5965 int dw_event_close(HEV *eve) | |
5966 { | |
5967 if(!eve || !(*eve)) | |
5968 return FALSE; | |
5969 | |
5970 pthread_mutex_lock (&((*eve)->mutex)); | |
5971 pthread_cond_destroy (&((*eve)->event)); | |
5972 pthread_mutex_unlock (&((*eve)->mutex)); | |
5973 pthread_mutex_destroy (&((*eve)->mutex)); | |
5974 free(*eve); | |
5975 *eve = NULL; | |
5976 | |
5977 return TRUE; | |
5978 } | |
5979 | |
5980 /* | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5981 * Setup thread independent color sets. |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5982 */ |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5983 void _dwthreadstart(void *data) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5984 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5985 void (*threadfunc)(void *) = NULL; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5986 void **tmp = (void **)data; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5987 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5988 threadfunc = (void (*)(void *))tmp[0]; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5989 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5990 _dw_thread_add(dw_thread_id()); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5991 threadfunc(tmp[1]); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5992 _dw_thread_remove(dw_thread_id()); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5993 free(tmp); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5994 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
5995 /* |
3 | 5996 * Creates a new thread with a starting point of func. |
5997 * Parameters: | |
5998 * func: Function which will be run in the new thread. | |
5999 * data: Parameter(s) passed to the function. | |
6000 * stack: Stack size of new thread (OS/2 and Windows only). | |
6001 */ | |
6002 DWTID dw_thread_new(void *func, void *data, int stack) | |
6003 { | |
6004 DWTID gtkthread; | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6005 void **tmp = malloc(sizeof(void *) * 2); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6006 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6007 tmp[0] = func; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6008 tmp[1] = data; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6009 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6010 pthread_create(>kthread, NULL, (void *)_dwthreadstart, (void *)tmp); |
3 | 6011 return gtkthread; |
6012 } | |
6013 | |
6014 /* | |
6015 * Ends execution of current thread immediately. | |
6016 */ | |
6017 void dw_thread_end(void) | |
6018 { | |
6019 pthread_exit(NULL); | |
6020 } | |
6021 | |
6022 /* | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6023 * Returns the current thread's ID. |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6024 */ |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6025 DWTID dw_thread_id(void) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6026 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6027 return (DWTID)pthread_self(); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6028 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6029 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6030 /* |
3 | 6031 * Cleanly terminates a DW session, should be signal handler safe. |
6032 * Parameters: | |
6033 * exitcode: Exit code reported to the operating system. | |
6034 */ | |
6035 void dw_exit(int exitcode) | |
6036 { | |
6037 exit(exitcode); | |
6038 } | |
6039 | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6040 #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
|
6041 |
3 | 6042 /* |
6043 * Pack windows (widgets) into a box from the end (or bottom). | |
6044 * Parameters: | |
6045 * box: Window handle of the box to be packed into. | |
6046 * item: Window handle of the item to be back. | |
6047 * width: Width in pixels of the item or -1 to be self determined. | |
6048 * height: Height in pixels of the item or -1 to be self determined. | |
6049 * hsize: TRUE if the window (widget) should expand horizontally to fill space given. | |
6050 * vsize: TRUE if the window (widget) should expand vertically to fill space given. | |
6051 * pad: Number of pixels of padding around the item. | |
6052 */ | |
6053 void dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) | |
6054 { | |
6055 int _locked_by_me = FALSE; | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6056 GtkWidget *tmp; |
3 | 6057 |
6058 if(!box) | |
6059 return; | |
6060 | |
6061 DW_MUTEX_LOCK; | |
6062 | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6063 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
|
6064 box = tmp; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6065 |
3 | 6066 if(!item) |
6067 { | |
6068 item = gtk_label_new(""); | |
6069 gtk_widget_show(item); | |
6070 } | |
6071 | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6072 if(GTK_IS_TABLE(box)) |
3 | 6073 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6074 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
|
6075 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
|
6076 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6077 /* 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
|
6078 * 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
|
6079 * 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
|
6080 * 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
|
6081 */ |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6082 if(GTK_IS_TABLE(item)) |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6083 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6084 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
|
6085 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6086 if(eventbox) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6087 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6088 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
|
6089 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
|
6090 item = eventbox; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6091 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6092 } |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6093 |
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
|
6094 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
|
6095 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
|
6096 else |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6097 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
|
6098 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6099 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
|
6100 gtk_object_set_data(GTK_OBJECT(box), "_dw_boxcount", (gpointer)boxcount + 1); |
3 | 6101 gtk_widget_set_usize(item, width, height); |
6102 if(GTK_IS_RADIO_BUTTON(item)) | |
6103 { | |
6104 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
|
6105 GtkWidget *groupstart = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(box), "_dw_group"); |
3 | 6106 |
6107 if(groupstart) | |
6108 { | |
6109 group = gtk_radio_button_group(GTK_RADIO_BUTTON(groupstart)); | |
6110 gtk_radio_button_set_group(GTK_RADIO_BUTTON(item), group); | |
6111 } | |
6112 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
|
6113 gtk_object_set_data(GTK_OBJECT(box), "_dw_group", (gpointer)item); |
3 | 6114 } |
6115 } | |
6116 else | |
6117 { | |
6118 GtkWidget *vbox = gtk_vbox_new(FALSE, 0); | |
6119 | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6120 if(GTK_IS_TABLE(item)) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6121 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6122 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
|
6123 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6124 if(eventbox) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6125 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6126 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
|
6127 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
|
6128 item = eventbox; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6129 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6130 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6131 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6132 gtk_container_border_width(GTK_CONTAINER(box), pad); |
3 | 6133 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
|
6134 gtk_box_pack_end(GTK_BOX(vbox), item, TRUE, TRUE, 0); |
3 | 6135 gtk_widget_show(vbox); |
6136 | |
6137 gtk_widget_set_usize(item, width, height); | |
6138 gtk_object_set_user_data(GTK_OBJECT(box), vbox); | |
6139 } | |
6140 DW_MUTEX_UNLOCK; | |
6141 } | |
6142 | |
6143 /* | |
6144 * Sets the size of a given window (widget). | |
6145 * Parameters: | |
6146 * handle: Window (widget) handle. | |
6147 * width: New width in pixels. | |
6148 * height: New height in pixels. | |
6149 */ | |
6150 void dw_window_set_usize(HWND handle, unsigned long width, unsigned long height) | |
6151 { | |
6152 int _locked_by_me = FALSE; | |
6153 | |
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
|
6154 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
|
6155 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
|
6156 |
3 | 6157 DW_MUTEX_LOCK; |
6158 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
|
6159 { |
3 | 6160 _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
|
6161 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
|
6162 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
|
6163 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
|
6164 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
|
6165 { |
49ac97060328
Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
271
diff
changeset
|
6166 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
|
6167 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
|
6168 } |
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
|
6169 } |
3 | 6170 else |
6171 gtk_widget_set_usize(handle, width, height); | |
6172 DW_MUTEX_UNLOCK; | |
6173 } | |
6174 | |
6175 /* | |
6176 * Returns the width of the screen. | |
6177 */ | |
6178 int dw_screen_width(void) | |
6179 { | |
6180 int retval; | |
6181 int _locked_by_me = FALSE; | |
6182 | |
6183 DW_MUTEX_LOCK; | |
6184 retval = gdk_screen_width(); | |
6185 DW_MUTEX_UNLOCK; | |
6186 return retval; | |
6187 } | |
6188 | |
6189 /* | |
6190 * Returns the height of the screen. | |
6191 */ | |
6192 int dw_screen_height(void) | |
6193 { | |
6194 int retval; | |
6195 int _locked_by_me = FALSE; | |
6196 | |
6197 DW_MUTEX_UNLOCK; | |
6198 retval = gdk_screen_height(); | |
6199 DW_MUTEX_UNLOCK; | |
6200 return retval; | |
6201 } | |
6202 | |
6203 /* This should return the current color depth */ | |
6204 unsigned long dw_color_depth(void) | |
6205 { | |
6206 int retval; | |
6207 int _locked_by_me = FALSE; | |
6208 | |
6209 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
|
6210 retval = gdk_visual_get_best_depth(); |
3 | 6211 DW_MUTEX_UNLOCK; |
6212 return retval; | |
6213 } | |
6214 | |
6215 /* | |
6216 * Sets the position of a given window (widget). | |
6217 * Parameters: | |
6218 * handle: Window (widget) handle. | |
6219 * x: X location from the bottom left. | |
6220 * y: Y location from the bottom left. | |
6221 */ | |
6222 void dw_window_set_pos(HWND handle, unsigned long x, unsigned long y) | |
6223 { | |
6224 int _locked_by_me = FALSE; | |
6225 | |
6226 DW_MUTEX_LOCK; | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
6227 if(handle && handle->window) |
3 | 6228 gdk_window_move(handle->window, x, y); |
6229 DW_MUTEX_UNLOCK; | |
6230 } | |
6231 | |
6232 /* | |
6233 * Sets the position and size of a given window (widget). | |
6234 * Parameters: | |
6235 * handle: Window (widget) handle. | |
6236 * x: X location from the bottom left. | |
6237 * y: Y location from the bottom left. | |
6238 * width: Width of the widget. | |
6239 * height: Height of the widget. | |
6240 */ | |
6241 void dw_window_set_pos_size(HWND handle, unsigned long x, unsigned long y, unsigned long width, unsigned long height) | |
6242 { | |
6243 int _locked_by_me = FALSE; | |
6244 | |
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
|
6245 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
|
6246 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
|
6247 |
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
|
6248 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
|
6249 if(GTK_IS_WINDOW(handle)) |
3 | 6250 { |
6251 _size_allocate(GTK_WINDOW(handle)); | |
15
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
6252 |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
6253 gtk_widget_set_uposition(handle, x, y); |
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
|
6254 if(handle->window) |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
6255 gdk_window_resize(handle->window, width - _dw_border_width, height - _dw_border_height); |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6256 gtk_window_set_default_size(GTK_WINDOW(handle), width - _dw_border_width, height - _dw_border_height); |
3 | 6257 } |
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
|
6258 else if(handle->window) |
3 | 6259 { |
6260 gdk_window_resize(handle->window, width, height); | |
6261 gdk_window_move(handle->window, x, y); | |
6262 } | |
6263 DW_MUTEX_UNLOCK; | |
6264 } | |
6265 | |
6266 /* | |
6267 * Gets the position and size of a given window (widget). | |
6268 * Parameters: | |
6269 * handle: Window (widget) handle. | |
6270 * x: X location from the bottom left. | |
6271 * y: Y location from the bottom left. | |
6272 * width: Width of the widget. | |
6273 * height: Height of the widget. | |
6274 */ | |
6275 void dw_window_get_pos_size(HWND handle, ULONG *x, ULONG *y, ULONG *width, ULONG *height) | |
6276 { | |
6277 int _locked_by_me = FALSE; | |
6278 gint gx, gy, gwidth, gheight, gdepth; | |
6279 | |
12
26e2130135b9
Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
7
diff
changeset
|
6280 if(handle && handle->window) |
3 | 6281 { |
6282 DW_MUTEX_LOCK; | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
6283 |
3 | 6284 gdk_window_get_geometry(handle->window, &gx, &gy, &gwidth, &gheight, &gdepth); |
6285 gdk_window_get_root_origin(handle->window, &gx, &gy); | |
6286 if(x) | |
6287 *x = gx; | |
6288 if(y) | |
6289 *y = gy; | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6290 if(GTK_IS_WINDOW(handle)) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6291 { |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6292 if(width) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6293 *width = gwidth + _dw_border_width; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6294 if(height) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6295 *height = gheight + _dw_border_height; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6296 } |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6297 else |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6298 { |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6299 if(width) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6300 *width = gwidth; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6301 if(height) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6302 *height = gheight; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6303 } |
3 | 6304 DW_MUTEX_UNLOCK; |
6305 } | |
6306 } | |
6307 | |
6308 /* | |
6309 * Sets the style of a given window (widget). | |
6310 * Parameters: | |
6311 * handle: Window (widget) handle. | |
6312 * width: New width in pixels. | |
6313 * height: New height in pixels. | |
6314 */ | |
6315 void dw_window_set_style(HWND handle, unsigned long style, unsigned long mask) | |
6316 { | |
6317 GtkWidget *handle2 = handle; | |
6318 int _locked_by_me = FALSE; | |
6319 | |
6320 DW_MUTEX_LOCK; | |
6321 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
6322 { | |
6323 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
6324 if(tmp) | |
6325 handle2 = tmp; | |
6326 } | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
6327 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
|
6328 { |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6329 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
|
6330 { |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6331 gfloat x, y; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6332 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6333 x = y = DW_LEFT; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6334 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6335 if(style & DW_DT_CENTER) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6336 x = DW_CENTER; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6337 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6338 if(style & DW_DT_VCENTER) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6339 y = DW_CENTER; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6340 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6341 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
|
6342 } |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6343 if(style & DW_DT_WORDBREAK) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
6344 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
|
6345 } |
3 | 6346 DW_MUTEX_UNLOCK; |
6347 } | |
6348 | |
6349 /* | |
6350 * Adds a new page to specified notebook. | |
6351 * Parameters: | |
6352 * handle: Window (widget) handle. | |
6353 * flags: Any additional page creation flags. | |
6354 * front: If TRUE page is added at the beginning. | |
6355 */ | |
6356 unsigned long dw_notebook_page_new(HWND handle, unsigned long flags, int front) | |
6357 { | |
6358 int z; | |
6359 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
|
6360 GtkWidget **pagearray; |
3 | 6361 |
6362 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
|
6363 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
|
6364 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6365 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
|
6366 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6367 for(z=0;z<256;z++) |
3 | 6368 { |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6369 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
|
6370 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6371 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
|
6372 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
|
6373 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6374 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
|
6375 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
|
6376 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6377 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
|
6378 /* 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
|
6379 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
|
6380 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
|
6381 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
|
6382 } |
3 | 6383 } |
15
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
6384 } |
3 | 6385 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
|
6386 |
3 | 6387 /* Hopefully this won't happen. */ |
6388 return 256; | |
6389 } | |
6390 | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6391 /* 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
|
6392 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
|
6393 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6394 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
|
6395 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
|
6396 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6397 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
|
6398 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6399 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
|
6400 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6401 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
|
6402 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6403 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
|
6404 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
|
6405 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6406 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6407 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6408 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
|
6409 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6410 |
3 | 6411 /* |
6412 * Remove a page from a notebook. | |
6413 * Parameters: | |
6414 * handle: Handle to the notebook widget. | |
6415 * pageid: ID of the page to be destroyed. | |
6416 */ | |
6417 void dw_notebook_page_destroy(HWND handle, unsigned int pageid) | |
6418 { | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6419 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
|
6420 GtkWidget **pagearray; |
3 | 6421 |
6422 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
|
6423 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
|
6424 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
|
6425 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6426 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
|
6427 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
|
6428 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
|
6429 } |
3 | 6430 DW_MUTEX_UNLOCK; |
6431 } | |
6432 | |
6433 /* | |
6434 * Queries the currently visible page ID. | |
6435 * Parameters: | |
6436 * handle: Handle to the notebook widget. | |
6437 */ | |
346
81fae15885d7
Implemented switch-page on OS/2, and changed the signal prototype to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
345
diff
changeset
|
6438 unsigned long dw_notebook_page_query(HWND handle) |
3 | 6439 { |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6440 int retval, phys; |
3 | 6441 int _locked_by_me = FALSE; |
6442 | |
6443 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
|
6444 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
|
6445 retval = _get_logical_page(handle, phys); |
3 | 6446 DW_MUTEX_UNLOCK; |
6447 return retval; | |
6448 } | |
6449 | |
6450 /* | |
6451 * Sets the currently visibale page ID. | |
6452 * Parameters: | |
6453 * handle: Handle to the notebook widget. | |
6454 * pageid: ID of the page to be made visible. | |
6455 */ | |
6456 void dw_notebook_page_set(HWND handle, unsigned int pageid) | |
6457 { | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6458 int realpage, _locked_by_me = FALSE; |
3 | 6459 |
6460 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
|
6461 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
|
6462 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
|
6463 gtk_notebook_set_page(GTK_NOTEBOOK(handle), pageid); |
3 | 6464 DW_MUTEX_UNLOCK; |
6465 } | |
6466 | |
6467 | |
6468 /* | |
6469 * Sets the text on the specified notebook tab. | |
6470 * Parameters: | |
6471 * handle: Notebook handle. | |
6472 * pageid: Page ID of the tab to set. | |
6473 * text: Pointer to the text to set. | |
6474 */ | |
6475 void dw_notebook_page_set_text(HWND handle, unsigned long pageid, char *text) | |
6476 { | |
6477 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
|
6478 int realpage, _locked_by_me = FALSE; |
3 | 6479 |
6480 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
|
6481 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
|
6482 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
|
6483 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6484 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
|
6485 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
|
6486 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6487 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
|
6488 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
|
6489 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
|
6490 } |
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 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
|
6493 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6494 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
|
6495 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
|
6496 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
|
6497 } |
3 | 6498 DW_MUTEX_UNLOCK; |
6499 } | |
6500 | |
6501 /* | |
6502 * Sets the text on the specified notebook tab status area. | |
6503 * Parameters: | |
6504 * handle: Notebook handle. | |
6505 * pageid: Page ID of the tab to set. | |
6506 * text: Pointer to the text to set. | |
6507 */ | |
6508 void dw_notebook_page_set_status_text(HWND handle, unsigned long pageid, char *text) | |
6509 { | |
6510 /* TODO (if possible) */ | |
6511 } | |
6512 | |
6513 /* | |
6514 * Packs the specified box into the notebook page. | |
6515 * Parameters: | |
6516 * handle: Handle to the notebook to be packed. | |
6517 * pageid: Page ID in the notebook which is being packed. | |
6518 * page: Box handle to be packed. | |
6519 */ | |
6520 void dw_notebook_pack(HWND handle, unsigned long pageid, HWND page) | |
6521 { | |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6522 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
|
6523 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
|
6524 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
|
6525 char ptext[100]; |
3 | 6526 |
6527 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
|
6528 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
|
6529 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
|
6530 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
|
6531 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
|
6532 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6533 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
|
6534 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6535 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
|
6536 return; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6537 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6538 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6539 /* 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
|
6540 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
|
6541 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6542 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
|
6543 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6544 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
|
6545 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
|
6546 { |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6547 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
|
6548 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
|
6549 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
|
6550 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
|
6551 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
|
6552 break; |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6553 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6554 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6555 } |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6556 |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6557 pagearray[pageid] = page; |
15
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
6558 |
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
6559 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
|
6560 |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6561 if(GTK_IS_TABLE(page)) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6562 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6563 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
|
6564 gtk_container_border_width(GTK_CONTAINER(page), pad); |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6565 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
6566 |
114
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6567 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
|
6568 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
|
6569 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
|
6570 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
|
6571 else |
39932767ef46
Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
112
diff
changeset
|
6572 gtk_notebook_insert_page(GTK_NOTEBOOK(handle), page, label, 256); |
3 | 6573 DW_MUTEX_UNLOCK; |
6574 } | |
6575 | |
6576 /* | |
6577 * Appends the specified text to the listbox's (or combobox) entry list. | |
6578 * Parameters: | |
6579 * handle: Handle to the listbox to be appended to. | |
6580 * text: Text to append into listbox. | |
6581 */ | |
6582 void dw_listbox_append(HWND handle, char *text) | |
6583 { | |
6584 GtkWidget *handle2 = handle; | |
6585 int _locked_by_me = FALSE; | |
6586 | |
6587 DW_MUTEX_LOCK; | |
6588 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
6589 { | |
6590 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
6591 if(tmp) | |
6592 handle2 = tmp; | |
6593 } | |
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 gtk_object_set_data(GTK_OBJECT(handle), "_dw_appending", (gpointer)1); |
3 | 6595 if(GTK_IS_LIST(handle2)) |
6596 { | |
6597 GtkWidget *list_item; | |
6598 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
|
6599 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
|
6600 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
|
6601 GdkColor *back = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle2), "_dw_backgdk"); |
3 | 6602 |
6603 list_item=gtk_list_item_new_with_label(text); | |
6604 | |
6605 if(font) | |
6606 _set_font(GTK_LIST_ITEM(list_item)->item.bin.child, font); | |
6607 if(fore && back) | |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
6608 _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
|
6609 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
|
6610 DW_RGB(back->red, back->green, back->blue)); |
3 | 6611 |
6612 tmp = g_list_append(NULL, list_item); | |
6613 gtk_widget_show(list_item); | |
6614 gtk_list_append_items(GTK_LIST(handle2),tmp); | |
6615 } | |
6616 else if(GTK_IS_COMBO(handle2)) | |
6617 { | |
6618 GList *tmp = (GList *)gtk_object_get_user_data(GTK_OBJECT(handle2)); | |
6619 char *addtext = strdup(text); | |
6620 | |
6621 if(addtext) | |
6622 { | |
6623 tmp = g_list_append(tmp, addtext); | |
6624 gtk_object_set_user_data(GTK_OBJECT(handle2), tmp); | |
6625 gtk_combo_set_popdown_strings(GTK_COMBO(handle2), tmp); | |
6626 } | |
6627 } | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6628 gtk_object_set_data(GTK_OBJECT(handle), "_dw_appending", NULL); |
3 | 6629 DW_MUTEX_UNLOCK; |
6630 } | |
6631 | |
6632 /* | |
6633 * Clears the listbox's (or combobox) list of all entries. | |
6634 * Parameters: | |
6635 * handle: Handle to the listbox to be cleared. | |
6636 */ | |
6637 void dw_listbox_clear(HWND handle) | |
6638 { | |
6639 GtkWidget *handle2 = handle; | |
6640 int _locked_by_me = FALSE; | |
6641 | |
6642 DW_MUTEX_LOCK; | |
6643 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
6644 { | |
6645 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
6646 if(tmp) | |
6647 handle2 = tmp; | |
6648 } | |
6649 if(GTK_IS_COMBO(handle2)) | |
6650 { | |
6651 GList *list, *tmp = (GList *)gtk_object_get_user_data(GTK_OBJECT(handle2)); | |
6652 | |
6653 if(tmp) | |
6654 { | |
6655 list = tmp; | |
6656 while(list) | |
6657 { | |
6658 if(list->data) | |
6659 free(list->data); | |
6660 list=list->next; | |
6661 } | |
6662 g_list_free(tmp); | |
6663 } | |
6664 gtk_object_set_user_data(GTK_OBJECT(handle2), NULL); | |
6665 } | |
6666 else if(GTK_IS_LIST(handle2)) | |
6667 { | |
6668 int count = dw_listbox_count(handle); | |
6669 | |
6670 gtk_list_clear_items(GTK_LIST(handle2), 0, count - 1); | |
6671 } | |
6672 DW_MUTEX_UNLOCK; | |
6673 } | |
6674 | |
6675 /* | |
6676 * Returns the listbox's item count. | |
6677 * Parameters: | |
6678 * handle: Handle to the listbox to be counted | |
6679 */ | |
6680 int dw_listbox_count(HWND handle) | |
6681 { | |
6682 GtkWidget *handle2 = handle; | |
6683 int retval = 0; | |
6684 int _locked_by_me = FALSE; | |
6685 | |
6686 DW_MUTEX_LOCK; | |
6687 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
6688 { | |
6689 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
6690 if(tmp) | |
6691 handle2 = tmp; | |
6692 } | |
6693 else if(GTK_IS_COMBO(handle)) | |
6694 { | |
6695 handle2 = GTK_COMBO(handle)->list; | |
6696 } | |
6697 if(GTK_IS_LIST(handle2)) | |
6698 { | |
6699 GList *list = GTK_LIST(handle2)->children; | |
6700 while(list) | |
6701 { | |
6702 list = list->next; | |
6703 retval++; | |
6704 } | |
6705 } | |
6706 DW_MUTEX_UNLOCK; | |
6707 return retval; | |
6708 } | |
6709 | |
6710 /* | |
6711 * Sets the topmost item in the viewport. | |
6712 * Parameters: | |
6713 * handle: Handle to the listbox to be cleared. | |
6714 * top: Index to the top item. | |
6715 */ | |
6716 void dw_listbox_set_top(HWND handle, int top) | |
6717 { | |
6718 GtkWidget *handle2 = handle; | |
6719 int _locked_by_me = FALSE; | |
6720 | |
6721 DW_MUTEX_LOCK; | |
6722 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
6723 { | |
6724 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
6725 if(tmp) | |
6726 handle2 = tmp; | |
6727 } | |
6728 if(GTK_IS_LIST(handle2)) | |
6729 { | |
6730 int count = dw_listbox_count(handle); | |
6731 GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(handle)); | |
6732 float pos, ratio; | |
6733 | |
6734 if(count) | |
6735 { | |
6736 ratio = (float)top/(float)count; | |
6737 | |
6738 pos = (ratio * (float)(adj->upper - adj->lower)) + adj->lower; | |
6739 | |
6740 gtk_adjustment_set_value(adj, pos); | |
6741 } | |
6742 } | |
6743 DW_MUTEX_UNLOCK; | |
6744 } | |
6745 | |
6746 /* | |
6747 * Copies the given index item's text into buffer. | |
6748 * Parameters: | |
6749 * handle: Handle to the listbox to be queried. | |
6750 * index: Index into the list to be queried. | |
6751 * buffer: Buffer where text will be copied. | |
6752 * length: Length of the buffer (including NULL). | |
6753 */ | |
6754 void dw_listbox_query_text(HWND handle, unsigned int index, char *buffer, unsigned int length) | |
6755 { | |
6756 GtkWidget *handle2 = handle; | |
6757 int _locked_by_me = FALSE; | |
6758 | |
6759 DW_MUTEX_LOCK; | |
6760 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
6761 { | |
6762 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
6763 if(tmp) | |
6764 handle2 = tmp; | |
6765 } | |
6766 else if(GTK_IS_COMBO(handle)) | |
6767 { | |
6768 handle2 = GTK_COMBO(handle)->list; | |
6769 } | |
6770 if(GTK_IS_LIST(handle2)) | |
6771 { | |
6772 int counter = 0; | |
6773 GList *list = GTK_LIST(handle2)->children; | |
6774 | |
6775 while(list) | |
6776 { | |
6777 if(counter == index) | |
6778 { | |
6779 gchar *text = ""; | |
6780 | |
6781 if(GTK_IS_LIST_ITEM(list->data)) | |
6782 { | |
6783 GtkListItem *li = GTK_LIST_ITEM(list->data); | |
6784 | |
6785 if(GTK_IS_ITEM(&(li->item))) | |
6786 { | |
6787 GtkItem *i = &(li->item); | |
6788 | |
6789 if(GTK_IS_BIN(&(i->bin))) | |
6790 { | |
6791 GtkBin *b = &(i->bin); | |
6792 | |
6793 if(GTK_IS_LABEL(b->child)) | |
6794 gtk_label_get(GTK_LABEL(b->child), &text); | |
6795 } | |
6796 } | |
6797 } | |
6798 else if(GTK_IS_COMBO(handle) && list->data) | |
6799 text = (gchar *)list->data; | |
6800 | |
6801 strncpy(buffer, (char *)text, length); | |
6802 break; | |
6803 } | |
6804 list = list->next; | |
6805 counter++; | |
6806 } | |
6807 } | |
6808 DW_MUTEX_UNLOCK; | |
6809 } | |
6810 | |
6811 /* | |
6812 * Sets the text of a given listbox entry. | |
6813 * Parameters: | |
6814 * handle: Handle to the listbox to be queried. | |
6815 * index: Index into the list to be queried. | |
6816 * buffer: Buffer where text will be copied. | |
6817 */ | |
6818 void dw_listbox_set_text(HWND handle, unsigned int index, char *buffer) | |
6819 { | |
6820 GtkWidget *handle2 = handle; | |
6821 int _locked_by_me = FALSE; | |
6822 | |
6823 DW_MUTEX_LOCK; | |
6824 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
6825 { | |
6826 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
6827 if(tmp) | |
6828 handle2 = tmp; | |
6829 } | |
6830 else if(GTK_IS_COMBO(handle)) | |
6831 { | |
6832 handle2 = GTK_COMBO(handle)->list; | |
6833 } | |
6834 if(GTK_IS_LIST(handle2)) | |
6835 { | |
6836 int counter = 0; | |
6837 GList *list = GTK_LIST(handle2)->children; | |
6838 | |
6839 while(list) | |
6840 { | |
6841 if(counter == index) | |
6842 { | |
6843 | |
6844 if(GTK_IS_LIST_ITEM(list->data)) | |
6845 { | |
6846 GtkListItem *li = GTK_LIST_ITEM(list->data); | |
6847 | |
6848 if(GTK_IS_ITEM(&(li->item))) | |
6849 { | |
6850 GtkItem *i = &(li->item); | |
6851 | |
6852 if(GTK_IS_BIN(&(i->bin))) | |
6853 { | |
6854 GtkBin *b = &(i->bin); | |
6855 | |
6856 if(GTK_IS_LABEL(b->child)) | |
6857 gtk_label_set_text(GTK_LABEL(b->child), buffer); | |
6858 } | |
6859 } | |
6860 } | |
6861 else if(GTK_IS_COMBO(handle)) | |
6862 { | |
6863 if(list->data) | |
6864 g_free(list->data); | |
6865 list->data = g_strdup(buffer); | |
6866 } | |
6867 break; | |
6868 } | |
6869 list = list->next; | |
6870 counter++; | |
6871 } | |
6872 } | |
6873 DW_MUTEX_UNLOCK; | |
6874 } | |
6875 | |
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
|
6876 #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
|
6877 /* 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
|
6878 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
|
6879 { |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
6880 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
|
6881 { |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
6882 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
|
6883 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
|
6884 |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
6885 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
|
6886 } |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
6887 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
|
6888 } |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
6889 #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
|
6890 |
3 | 6891 /* |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6892 * 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
|
6893 * Parameters: |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6894 * 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
|
6895 * 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
|
6896 */ |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6897 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
|
6898 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6899 GtkWidget *handle2 = handle; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6900 int retval = DW_LIT_NONE; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6901 int _locked_by_me = FALSE; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6902 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6903 DW_MUTEX_LOCK; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6904 if(GTK_IS_SCROLLED_WINDOW(handle)) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6905 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6906 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
|
6907 if(tmp) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6908 handle2 = tmp; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6909 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6910 if(GTK_IS_LIST(handle2)) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6911 { |
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
|
6912 #if GTK_MAJOR_VERSION > 1 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6913 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
|
6914 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
|
6915 |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6916 while(list) |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6917 { |
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
|
6918 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
|
6919 |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
6920 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
|
6921 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
|
6922 && 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
|
6923 { |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
6924 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
|
6925 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
|
6926 } |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
6927 |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
6928 |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
6929 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
|
6930 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
|
6931 } |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
6932 #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
|
6933 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
|
6934 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
|
6935 |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
6936 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
|
6937 { |
b479002e013f
Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
145
diff
changeset
|
6938 if(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
|
6939 { |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6940 retval = counter; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6941 break; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6942 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6943 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6944 list = list->next; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6945 counter++; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6946 } |
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
|
6947 #endif |
60
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6948 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6949 DW_MUTEX_UNLOCK; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6950 return retval; |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6951 } |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6952 |
61869769c050
Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
57
diff
changeset
|
6953 /* |
3 | 6954 * Returns the index to the item in the list currently selected. |
6955 * Parameters: | |
6956 * handle: Handle to the listbox to be queried. | |
6957 */ | |
6958 unsigned int dw_listbox_selected(HWND handle) | |
6959 { | |
6960 GtkWidget *handle2 = handle; | |
6961 int retval = DW_LIT_NONE; | |
6962 int _locked_by_me = FALSE; | |
6963 | |
6964 DW_MUTEX_LOCK; | |
6965 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
6966 { | |
6967 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
6968 if(tmp) | |
6969 handle2 = tmp; | |
6970 } | |
6971 else if(GTK_IS_COMBO(handle)) | |
6972 { | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
6973 retval = (unsigned int)gtk_object_get_data(GTK_OBJECT(handle), "_dw_item"); |
3 | 6974 DW_MUTEX_UNLOCK; |
6975 return retval; | |
6976 } | |
6977 if(GTK_IS_LIST(handle2)) | |
6978 { | |
6979 int counter = 0; | |
6980 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
|
6981 #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
|
6982 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
|
6983 #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
|
6984 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
|
6985 #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
|
6986 if(selection) |
3 | 6987 { |
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
|
6988 while(list) |
3 | 6989 { |
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
|
6990 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
|
6991 { |
b479002e013f
Upped the 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 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
|
6993 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
|
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 |
b479002e013f
Upped the 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 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
|
6997 counter++; |
3 | 6998 } |
6999 } | |
7000 } | |
7001 DW_MUTEX_UNLOCK; | |
7002 return retval; | |
7003 } | |
7004 | |
7005 /* | |
7006 * Sets the selection state of a given index. | |
7007 * Parameters: | |
7008 * handle: Handle to the listbox to be set. | |
7009 * index: Item index. | |
7010 * state: TRUE if selected FALSE if unselected. | |
7011 */ | |
7012 void dw_listbox_select(HWND handle, int index, int state) | |
7013 { | |
7014 GtkWidget *handle2 = handle; | |
7015 int _locked_by_me = FALSE; | |
7016 | |
7017 DW_MUTEX_LOCK; | |
7018 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
7019 { | |
7020 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
7021 if(tmp) | |
7022 handle2 = tmp; | |
7023 } | |
7024 else if(GTK_IS_COMBO(handle)) | |
7025 { | |
7026 handle2 = GTK_COMBO(handle)->list; | |
7027 } | |
7028 if(GTK_IS_LIST(handle2)) | |
7029 { | |
7030 if(state) | |
7031 gtk_list_select_item(GTK_LIST(handle2), index); | |
7032 else | |
7033 gtk_list_unselect_item(GTK_LIST(handle2), index); | |
7034 } | |
7035 DW_MUTEX_UNLOCK; | |
7036 } | |
7037 | |
7038 /* | |
7039 * Deletes the item with given index from the list. | |
7040 * Parameters: | |
7041 * handle: Handle to the listbox to be set. | |
7042 * index: Item index. | |
7043 */ | |
7044 void dw_listbox_delete(HWND handle, int index) | |
7045 { | |
7046 GtkWidget *handle2 = handle; | |
7047 int _locked_by_me = FALSE; | |
7048 | |
7049 DW_MUTEX_LOCK; | |
7050 if(GTK_IS_SCROLLED_WINDOW(handle)) | |
7051 { | |
7052 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); | |
7053 if(tmp) | |
7054 handle2 = tmp; | |
7055 } | |
7056 else if(GTK_IS_COMBO(handle)) | |
7057 { | |
7058 handle2 = GTK_COMBO(handle)->list; | |
7059 } | |
7060 if(GTK_IS_LIST(handle2)) | |
7061 gtk_list_clear_items(GTK_LIST(handle2), index, index); | |
7062 DW_MUTEX_UNLOCK; | |
7063 } | |
7064 | |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7065 /* 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
|
7066 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
|
7067 { |
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
|
7068 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
|
7069 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
|
7070 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
|
7071 |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7072 /* 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
|
7073 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
|
7074 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
|
7075 |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7076 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
|
7077 |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7078 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
|
7079 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
|
7080 |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7081 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
|
7082 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
|
7083 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
|
7084 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
|
7085 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
|
7086 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
|
7087 } |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7088 |
122
a05b6fb9c545
Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
121
diff
changeset
|
7089 #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
|
7090 /* 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
|
7091 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
|
7092 { |
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7093 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
|
7094 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
|
7095 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
|
7096 |
145
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7097 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
|
7098 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
|
7099 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7100 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
|
7101 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
|
7102 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
|
7103 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
|
7104 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7105 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
|
7106 *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
|
7107 } |
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
|
7108 #endif |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7109 |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7110 /* |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7111 * 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
|
7112 * 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
|
7113 * 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
|
7114 * 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
|
7115 * 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
|
7116 * Returns: |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7117 * 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
|
7118 */ |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7119 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
|
7120 { |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7121 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
|
7122 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
|
7123 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
|
7124 |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7125 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
|
7126 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
|
7127 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
|
7128 else |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7129 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
|
7130 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
|
7131 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
|
7132 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
|
7133 *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
|
7134 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
|
7135 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
|
7136 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
|
7137 #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
|
7138 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
|
7139 #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
|
7140 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
|
7141 #endif |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7142 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
|
7143 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
|
7144 return tmp; |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7145 } |
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 /* |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7148 * 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
|
7149 * Parameters: |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7150 * 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
|
7151 */ |
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
|
7152 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
|
7153 { |
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
|
7154 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
|
7155 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
|
7156 |
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7157 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
|
7158 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
|
7159 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
|
7160 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
|
7161 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7162 if(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
|
7163 *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
|
7164 |
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7165 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
|
7166 { |
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7167 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
|
7168 |
659c1a2bccad
Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
144
diff
changeset
|
7169 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
|
7170 } |
119
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7171 } |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7172 |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7173 /* |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7174 * 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
|
7175 * Parameters: |
1cad81b7cc4c
Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
115
diff
changeset
|
7176 * 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
|
7177 */ |
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
|
7178 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
|
7179 { |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7180 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
|
7181 |
7d2108cbcd3e
Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
119
diff
changeset
|
7182 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
|
7183 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
|
7184 return 0.0; |
3 | 7185 } |
7186 | |
7187 /* | |
7188 * Pack windows (widgets) into a box from the start (or top). | |
7189 * Parameters: | |
7190 * box: Window handle of the box to be packed into. | |
7191 * item: Window handle of the item to be back. | |
7192 * width: Width in pixels of the item or -1 to be self determined. | |
7193 * height: Height in pixels of the item or -1 to be self determined. | |
7194 * hsize: TRUE if the window (widget) should expand horizontally to fill space given. | |
7195 * vsize: TRUE if the window (widget) should expand vertically to fill space given. | |
7196 * pad: Number of pixels of padding around the item. | |
7197 */ | |
7198 void dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) | |
7199 { | |
7200 int _locked_by_me = FALSE; | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
7201 GtkWidget *tmp; |
3 | 7202 |
7203 if(!box) | |
7204 return; | |
7205 | |
7206 DW_MUTEX_LOCK; | |
7207 | |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7208 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
|
7209 box = tmp; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
7210 |
3 | 7211 if(!item) |
7212 { | |
7213 item = gtk_label_new(""); | |
7214 gtk_widget_show(item); | |
7215 } | |
7216 | |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7217 if(GTK_IS_TABLE(box)) |
3 | 7218 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7219 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
|
7220 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
|
7221 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
|
7222 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7223 /* 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
|
7224 * 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
|
7225 * 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
|
7226 * 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
|
7227 */ |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7228 if(GTK_IS_TABLE(item)) |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7229 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7230 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
|
7231 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7232 if(eventbox) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7233 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7234 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
|
7235 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
|
7236 item = eventbox; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7237 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7238 } |
36
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7239 |
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
|
7240 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
|
7241 { |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7242 x = 0; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7243 y = boxcount; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7244 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
|
7245 } |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7246 else |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7247 { |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7248 x = boxcount; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7249 y = 0; |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7250 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
|
7251 } |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7252 |
cddb02f847e1
Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
34
diff
changeset
|
7253 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
|
7254 gtk_object_set_data(GTK_OBJECT(box), "_dw_boxcount", (gpointer)boxcount + 1); |
3 | 7255 gtk_widget_set_usize(item, width, height); |
7256 if(GTK_IS_RADIO_BUTTON(item)) | |
7257 { | |
7258 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
|
7259 GtkWidget *groupstart = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(box), "_dw_group"); |
3 | 7260 |
7261 if(groupstart) | |
7262 { | |
7263 group = gtk_radio_button_group(GTK_RADIO_BUTTON(groupstart)); | |
7264 gtk_radio_button_set_group(GTK_RADIO_BUTTON(item), group); | |
7265 } | |
7266 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
|
7267 gtk_object_set_data(GTK_OBJECT(box), "_dw_group", (gpointer)item); |
3 | 7268 } |
7269 } | |
7270 else | |
7271 { | |
7272 GtkWidget *vbox = gtk_vbox_new(FALSE, 0); | |
7273 | |
48
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7274 if(GTK_IS_TABLE(item)) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7275 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7276 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
|
7277 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7278 if(eventbox) |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7279 { |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7280 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
|
7281 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
|
7282 item = eventbox; |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7283 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7284 } |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7285 |
16eac0f8b45f
Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
47
diff
changeset
|
7286 gtk_container_border_width(GTK_CONTAINER(box), pad); |
3 | 7287 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
|
7288 gtk_box_pack_end(GTK_BOX(vbox), item, TRUE, TRUE, 0); |
3 | 7289 gtk_widget_show(vbox); |
7290 | |
7291 gtk_widget_set_usize(item, width, height); | |
7292 gtk_object_set_user_data(GTK_OBJECT(box), vbox); | |
7293 } | |
7294 DW_MUTEX_UNLOCK; | |
7295 } | |
7296 | |
7297 /* | |
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
|
7298 * 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
|
7299 * 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
|
7300 * 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
|
7301 * 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
|
7302 */ |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
7303 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
|
7304 { |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
7305 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
|
7306 |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
7307 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
|
7308 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
|
7309 |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
7310 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
|
7311 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
|
7312 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
|
7313 } |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
7314 |
b03b24bb95f8
Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
33
diff
changeset
|
7315 /* |
40
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7316 * 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
|
7317 * Parameters: |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7318 * 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
|
7319 * 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
|
7320 */ |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7321 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
|
7322 { |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7323 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
|
7324 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7325 if(!window) |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7326 return; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7327 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7328 DW_MUTEX_LOCK; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7329 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
|
7330 DW_MUTEX_UNLOCK; |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7331 } |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7332 |
88c9c7410c22
Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
39
diff
changeset
|
7333 /* |
3 | 7334 * Returns some information about the current operating environment. |
7335 * Parameters: | |
7336 * env: Pointer to a DWEnv struct. | |
7337 */ | |
7338 void dw_environment_query(DWEnv *env) | |
7339 { | |
7340 struct utsname name; | |
7341 char tempbuf[100]; | |
7342 int len, z; | |
7343 | |
7344 uname(&name); | |
7345 strcpy(env->osName, name.sysname); | |
7346 strcpy(tempbuf, name.release); | |
7347 | |
7348 env->MajorBuild = env->MinorBuild = 0; | |
7349 | |
7350 len = strlen(tempbuf); | |
7351 | |
15
81833f25b1aa
Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
14
diff
changeset
|
7352 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
|
7353 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
|
7354 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
|
7355 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
|
7356 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
|
7357 |
3 | 7358 for(z=1;z<len;z++) |
7359 { | |
7360 if(tempbuf[z] == '.') | |
7361 { | |
7362 tempbuf[z] = '\0'; | |
7363 env->MajorVersion = atoi(&tempbuf[z-1]); | |
7364 env->MinorVersion = atoi(&tempbuf[z+1]); | |
7365 return; | |
7366 } | |
7367 } | |
7368 env->MajorVersion = atoi(tempbuf); | |
7369 env->MinorVersion = 0; | |
7370 } | |
7371 | |
7372 /* 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
|
7373 static gint _gtk_file_ok(GtkWidget *widget, DWDialog *dwwait) |
3 | 7374 { |
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
|
7375 #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
|
7376 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
|
7377 #else |
3 | 7378 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
|
7379 #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
|
7380 char *tmpdup=NULL; |
3 | 7381 |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
7382 if(!dwwait) |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
7383 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
|
7384 |
214
0e98514a3905
Applied patch from Mark Hessling to prevent the return buffer from the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
208
diff
changeset
|
7385 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
|
7386 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
|
7387 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
|
7388 _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
|
7389 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
|
7390 return FALSE; |
3 | 7391 } |
7392 | |
7393 /* 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
|
7394 static gint _gtk_file_cancel(GtkWidget *widget, DWDialog *dwwait) |
3 | 7395 { |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
7396 if(!dwwait) |
134
caeb52bb5ef4
Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
133
diff
changeset
|
7397 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
|
7398 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
7399 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
|
7400 _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
|
7401 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
|
7402 return FALSE; |
3 | 7403 } |
7404 | |
7405 /* | |
7406 * Opens a file dialog and queries user selection. | |
7407 * Parameters: | |
7408 * title: Title bar text for dialog. | |
7409 * defpath: The default path of the open dialog. | |
7410 * ext: Default file extention. | |
7411 * flags: DW_FILE_OPEN or DW_FILE_SAVE. | |
7412 * Returns: | |
7413 * NULL on error. A malloced buffer containing | |
7414 * the file path on success. | |
7415 * | |
7416 */ | |
7417 char *dw_file_browse(char *title, char *defpath, char *ext, int flags) | |
7418 { | |
7419 GtkWidget *filew; | |
7420 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
|
7421 DWDialog *dwwait; |
3 | 7422 |
7423 DW_MUTEX_LOCK; | |
7424 | |
7425 /* The DW mutex should be sufficient for | |
7426 * insuring no thread changes this unknowingly. | |
7427 */ | |
7428 if(_dw_file_active) | |
7429 { | |
7430 DW_MUTEX_UNLOCK; | |
7431 return NULL; | |
7432 } | |
7433 | |
7434 _dw_file_active = 1; | |
7435 | |
7436 filew = gtk_file_selection_new(title); | |
7437 | |
22
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
7438 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
|
7439 |
6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
19
diff
changeset
|
7440 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
|
7441 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filew)->cancel_button), "clicked", (GtkSignalFunc) _gtk_file_cancel, dwwait); |
3 | 7442 |
7443 if(defpath) | |
7444 gtk_file_selection_set_filename(GTK_FILE_SELECTION(filew), defpath); | |
7445 | |
7446 gtk_widget_show(filew); | |
7447 | |
7448 DW_MUTEX_UNLOCK; | |
7449 | |
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 return (char *)dw_dialog_wait(dwwait); |
3 | 7451 } |
7452 | |
7453 | |
7454 /* | |
7455 * Execute and external program in a seperate session. | |
7456 * Parameters: | |
7457 * program: Program name with optional path. | |
7458 * type: Either DW_EXEC_CON or DW_EXEC_GUI. | |
7459 * params: An array of pointers to string arguements. | |
7460 * Returns: | |
7461 * -1 on error. | |
7462 */ | |
7463 int dw_exec(char *program, int type, char **params) | |
7464 { | |
7465 int ret = -1; | |
7466 | |
7467 if((ret = fork()) == 0) | |
7468 { | |
7469 int i; | |
7470 | |
7471 for (i = 3; i < 256; i++) | |
7472 close(i); | |
7473 setsid(); | |
7474 if(type == DW_EXEC_GUI) | |
7475 { | |
7476 execvp(program, params); | |
7477 } | |
7478 else if(type == DW_EXEC_CON) | |
7479 { | |
7480 char **tmpargs; | |
7481 | |
7482 if(!params) | |
7483 { | |
7484 tmpargs = malloc(sizeof(char *)); | |
7485 tmpargs[0] = NULL; | |
7486 } | |
7487 else | |
7488 { | |
7489 int z = 0; | |
7490 | |
7491 while(params[z]) | |
7492 { | |
7493 z++; | |
7494 } | |
7495 tmpargs = malloc(sizeof(char *)*(z+3)); | |
7496 z=0; | |
7497 tmpargs[0] = "xterm"; | |
7498 tmpargs[1] = "-e"; | |
7499 while(params[z]) | |
7500 { | |
7501 tmpargs[z+2] = params[z]; | |
7502 z++; | |
7503 } | |
7504 tmpargs[z+2] = NULL; | |
7505 } | |
7506 execvp("xterm", tmpargs); | |
7507 free(tmpargs); | |
7508 } | |
7509 /* If we got here exec failed */ | |
7510 _exit(-1); | |
7511 } | |
7512 return ret; | |
7513 } | |
7514 | |
7515 /* | |
7516 * Loads a web browser pointed at the given URL. | |
7517 * Parameters: | |
7518 * url: Uniform resource locator. | |
7519 */ | |
7520 int dw_browse(char *url) | |
7521 { | |
7522 /* Is there a way to find the webbrowser in Unix? */ | |
7523 char *execargs[3], *browser = "netscape"; | |
7524 | |
7525 execargs[0] = browser; | |
7526 execargs[1] = url; | |
7527 execargs[2] = NULL; | |
7528 | |
7529 return dw_exec(browser, DW_EXEC_GUI, execargs); | |
7530 } | |
7531 | |
7532 /* | |
7533 * Returns a pointer to a static buffer which containes the | |
7534 * current user directory. Or the root directory (C:\ on | |
7535 * OS/2 and Windows). | |
7536 */ | |
7537 char *dw_user_dir(void) | |
7538 { | |
7539 static char _user_dir[1024] = ""; | |
7540 | |
7541 if(!_user_dir[0]) | |
7542 { | |
7543 char *home = getenv("HOME"); | |
7544 | |
7545 if(home) | |
7546 strcpy(_user_dir, home); | |
7547 else | |
7548 strcpy(_user_dir, "/"); | |
7549 } | |
7550 return _user_dir; | |
7551 } | |
7552 | |
7553 /* | |
7554 * Call a function from the window (widget)'s context. | |
7555 * Parameters: | |
7556 * handle: Window handle of the widget. | |
7557 * function: Function pointer to be called. | |
7558 * data: Pointer to the data to be passed to the function. | |
7559 */ | |
7560 void dw_window_function(HWND handle, void *function, void *data) | |
7561 { | |
37
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
7562 void (* windowfunc)(void *); |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
7563 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
7564 windowfunc = function; |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
7565 |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
7566 if(windowfunc) |
360bc6a5f1c9
Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
36
diff
changeset
|
7567 windowfunc(data); |
3 | 7568 } |
7569 | |
90
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7570 /* |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7571 * 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
|
7572 * Parameters: |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7573 * 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
|
7574 * 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
|
7575 * 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
|
7576 */ |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7577 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
|
7578 { |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7579 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
|
7580 |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7581 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
|
7582 return; |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7583 |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7584 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
|
7585 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
|
7586 { |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
7587 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
|
7588 { |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
7589 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
|
7590 |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
7591 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
|
7592 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
|
7593 } |
cf0115e38ef0
On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
107
diff
changeset
|
7594 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
|
7595 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
|
7596 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
|
7597 } |
90
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7598 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
|
7599 } |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7600 |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7601 /* |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7602 * 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
|
7603 * Parameters: |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7604 * 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
|
7605 * 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
|
7606 * 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
|
7607 */ |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7608 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
|
7609 { |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7610 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
|
7611 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
|
7612 |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7613 if(!window) |
92
0a085f295e81
A couple more minor changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
91
diff
changeset
|
7614 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
|
7615 |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7616 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
|
7617 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
|
7618 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
|
7619 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
|
7620 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
|
7621 } |
eeb98f881663
Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
87
diff
changeset
|
7622 |
3 | 7623 /* |
195
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7624 * 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
|
7625 * Parameters: |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7626 * 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
|
7627 * 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
|
7628 * 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
|
7629 * Returns: |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7630 * 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
|
7631 */ |
199
b955228477b3
Removed the window parameter to dw_timer_connect() it was no needed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
198
diff
changeset
|
7632 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
|
7633 { |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7634 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
|
7635 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7636 DW_MUTEX_LOCK; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7637 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
|
7638 DW_MUTEX_UNLOCK; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7639 return tag; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7640 } |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7641 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7642 /* |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7643 * Removes timer callback. |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7644 * Parameters: |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7645 * 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
|
7646 */ |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7647 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
|
7648 { |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7649 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
|
7650 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7651 DW_MUTEX_LOCK; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7652 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
|
7653 DW_MUTEX_UNLOCK; |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7654 } |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7655 |
b023d363fc09
Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
193
diff
changeset
|
7656 /* |
3 | 7657 * Add a callback to a window event. |
7658 * Parameters: | |
7659 * window: Window handle of signal to be called back. | |
7660 * signame: A string pointer identifying which signal to be hooked. | |
7661 * sigfunc: The pointer to the function to be used as the callback. | |
7662 * data: User data to be passed to the handler function. | |
7663 */ | |
7664 void dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data) | |
7665 { | |
7666 void *thisfunc = _findsigfunc(signame); | |
7667 char *thisname = signame; | |
7668 HWND thiswindow = window; | |
7669 int _locked_by_me = FALSE; | |
7670 | |
7671 DW_MUTEX_LOCK; | |
7672 if(GTK_IS_SCROLLED_WINDOW(thiswindow)) | |
7673 { | |
7674 thiswindow = (HWND)gtk_object_get_user_data(GTK_OBJECT(window)); | |
7675 } | |
7676 | |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7677 if(GTK_IS_MENU_ITEM(thiswindow) && strcmp(signame, DW_SIGNAL_CLICKED) == 0) |
3 | 7678 { |
7679 thisname = "activate"; | |
7680 thisfunc = _findsigfunc(thisname); | |
7681 } | |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7682 else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_CONTEXT) == 0) |
3 | 7683 { |
7684 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
|
7685 thisfunc = _findsigfunc(DW_SIGNAL_ITEM_CONTEXT); |
3 | 7686 } |
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
|
7687 #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
|
7688 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
|
7689 { |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
7690 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
|
7691 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
7692 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
|
7693 (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
|
7694 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
|
7695 (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
|
7696 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
|
7697 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
|
7698 } |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7699 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
|
7700 { |
362
eb61b854fd58
Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
361
diff
changeset
|
7701 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
|
7702 |
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
|
7703 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
|
7704 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
|
7705 |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
7706 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
|
7707 (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
|
7708 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
|
7709 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
|
7710 } |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
7711 #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
|
7712 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
|
7713 { |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
7714 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
|
7715 |
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
|
7716 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
|
7717 |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7718 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
|
7719 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
|
7720 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
|
7721 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
|
7722 (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
|
7723 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
|
7724 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
|
7725 } |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7726 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
|
7727 { |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
7728 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
|
7729 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7730 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
|
7731 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
|
7732 (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
|
7733 } |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
7734 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
|
7735 } |
e0e73b4372a6
GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
139
diff
changeset
|
7736 #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
|
7737 else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_ENTER) == 0) |
3 | 7738 { |
364
aa827971da39
Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
362
diff
changeset
|
7739 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
|
7740 (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
|
7741 |
3 | 7742 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
|
7743 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
|
7744 } |
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7745 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
|
7746 { |
d35771f70bdd
Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
163
diff
changeset
|
7747 thisname = "select_row"; |
d35771f70bdd
Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
163
diff
changeset
|
7748 thisfunc = (void *)_container_select_row; |
d35771f70bdd
Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
163
diff
changeset
|
7749 } |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7750 else if(GTK_IS_COMBO(thiswindow) && strcmp(signame, DW_SIGNAL_LIST_SELECT) == 0) |
3 | 7751 { |
7752 thisname = "select_child"; | |
7753 thiswindow = GTK_COMBO(thiswindow)->list; | |
7754 } | |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7755 else if(GTK_IS_LIST(thiswindow) && strcmp(signame, DW_SIGNAL_LIST_SELECT) == 0) |
3 | 7756 { |
7757 thisname = "select_child"; | |
7758 } | |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7759 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
|
7760 { |
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
diff
changeset
|
7761 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
|
7762 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
|
7763 thiswindow = GTK_COMBO(thiswindow)->entry; |
14
176cee043f1b
Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
12
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 #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
|
7766 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
|
7767 { |
b6948eac375a
Sync with the latest dynamic windows, tree fixes, and other miscellaneous
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
54
diff
changeset
|
7768 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
|
7769 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
|
7770 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
|
7771 } |
307
324587c06cea
Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
296
diff
changeset
|
7772 #endif |
205
b9283fd56d69
Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
202
diff
changeset
|
7773 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
|
7774 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
|
7775 { |
358
526642f70ddd
Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
357
diff
changeset
|
7776 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
|
7777 } |
331
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
7778 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
|
7779 { |
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
7780 thisname = "switch-page"; |
20def3eaae8d
Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents:
329
diff
changeset
|
7781 } |
3 | 7782 |
7783 if(!thisfunc || !thiswindow) | |
7784 { | |
7785 DW_MUTEX_UNLOCK; | |
7786 return; | |
7787 } | |
7788 | |
361
8c0212f70914
Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
359
diff
changeset
|
7789 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
|
7790 (gpointer)_set_signal_handler(thiswindow, window, sigfunc, data)); |
3 | 7791 DW_MUTEX_UNLOCK; |
7792 } | |
7793 | |
7794 /* | |
7795 * Removes callbacks for a given window with given name. | |
7796 * Parameters: | |
7797 * window: Window handle of callback to be removed. | |
7798 */ | |
7799 void dw_signal_disconnect_by_name(HWND window, char *signame) | |
7800 { | |
7801 #if 0 | |
7802 gtk_signal_disconnect_by_name(window, signame); | |
7803 #endif | |
7804 } | |
7805 | |
7806 /* | |
7807 * Removes all callbacks for a given window. | |
7808 * Parameters: | |
7809 * window: Window handle of callback to be removed. | |
7810 */ | |
7811 void dw_signal_disconnect_by_window(HWND window) | |
7812 { | |
7813 #if 0 | |
7814 gtk_signal_disconnect_by_window(window); | |
7815 #endif | |
7816 } | |
7817 | |
7818 /* | |
7819 * Removes all callbacks for a given window with specified data. | |
7820 * Parameters: | |
7821 * window: Window handle of callback to be removed. | |
7822 * data: Pointer to the data to be compared against. | |
7823 */ | |
7824 void dw_signal_disconnect_by_data(HWND window, void *data) | |
7825 { | |
7826 dw_signal_disconnect_by_data(window, data); | |
7827 } | |
153
a371875d5486
Sync up with the latest F/X sources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
151
diff
changeset
|
7828 |