annotate gtk/dw.c @ 350:2216e65ad2ae

Removed slider flags and container selection flags from the header file. Added "multi" parameter to dw_container_new() to control multiple selection.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 14 Apr 2003 13:47:20 +0000
parents 81fae15885d7
children feed7567764f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2 * Dynamic Windows:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3 * A GTK like implementation of the PM GUI
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4 * GTK forwarder module for portabilty.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5 *
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 282
diff changeset
6 * (C) 2000-2003 Brian Smith <dbsoft@technologist.com>
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7 *
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9 #include "dw.h"
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10 #include <string.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11 #include <stdlib.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12 #include <sys/utsname.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
13 #include <stdarg.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
14 #include <stdio.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
15 #include <unistd.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
16 #include <errno.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
17 #include <sys/time.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
18 #include "config.h"
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
19 #include <gdk/gdkkeysyms.h>
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
20 #ifdef USE_IMLIB
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
21 #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
22 #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
23 #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
24 #include <gdk-pixbuf/gdk-pixbuf.h>
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
25 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
26
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
27 /* These are used for resource management */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
28 #if defined(DW_RESOURCES) && !defined(BUILD_DLL)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
29 extern DWResources _resources;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
30 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
31
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
32 GdkColor _colors[] =
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
33 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
34 { 0, 0x0000, 0x0000, 0x0000 }, /* 0 black */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
35 { 0, 0xbbbb, 0x0000, 0x0000 }, /* 1 red */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
36 { 0, 0x0000, 0xbbbb, 0x0000 }, /* 2 green */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
37 { 0, 0xaaaa, 0xaaaa, 0x0000 }, /* 3 yellow */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
38 { 0, 0x0000, 0x0000, 0xcccc }, /* 4 blue */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
39 { 0, 0xbbbb, 0x0000, 0xbbbb }, /* 5 magenta */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
40 { 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
41 { 0, 0xbbbb, 0xbbbb, 0xbbbb }, /* 7 white */
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
42 { 0, 0x7777, 0x7777, 0x7777 }, /* 8 grey */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
43 { 0, 0xffff, 0x0000, 0x0000 }, /* 9 bright red */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
44 { 0, 0x0000, 0xffff, 0x0000 }, /* 10 bright green */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
45 { 0, 0xeeee, 0xeeee, 0x0000 }, /* 11 bright yellow */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
46 { 0, 0x0000, 0x0000, 0xffff }, /* 12 bright blue */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
47 { 0, 0xffff, 0x0000, 0xffff }, /* 13 bright magenta */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
48 { 0, 0x0000, 0xeeee, 0xeeee }, /* 14 bright cyan */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
49 { 0, 0xffff, 0xffff, 0xffff }, /* 15 bright white */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
50 };
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
51
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
52 #define DW_THREAD_LIMIT 50
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
53
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
54 DWTID _dw_thread_list[DW_THREAD_LIMIT];
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
55 GdkColor _foreground[DW_THREAD_LIMIT];
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
56 GdkColor _background[DW_THREAD_LIMIT];
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
57
93
98cce029a611 Changed handling of menu item click events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 92
diff changeset
58 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
59
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
60 static int _dw_file_active = 0, _dw_ignore_click = 0, _dw_unselecting = 0;
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
61 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
62 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
63 /* 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
64 static int _dw_border_width = 12, _dw_border_height = 28;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
65
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
66 #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
67 #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
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
68
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
69 #define DEFAULT_SIZE_WIDTH 12
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
70 #define DEFAULT_SIZE_HEIGHT 6
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
71 #define DEFAULT_TITLEBAR_HEIGHT 22
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
72
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
73 static GdkColormap *_dw_cmap = NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
74
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
75 /* 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
76 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
77 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
78 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
79 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
80 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
81 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
82 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
83 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
84 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
85 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
86 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
87 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
88 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
89 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
90 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
91 #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
92 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
93 #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
94 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
95 #endif
331
20def3eaae8d Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 329
diff changeset
96 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
97
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
98 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
99 {
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
100 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
101 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
102 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
103 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
104 #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
105 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
106 #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
107 } DWPrivatePixmap;
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
108
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
109 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
110 static int _PixmapCount = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
111
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
112 typedef struct
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
113 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
114 void *func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
115 char name[30];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
116
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
117 } SignalList;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
118
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
119 typedef struct
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
120 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
121 HWND window;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
122 void *func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
123 gpointer data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
124
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
125 } SignalHandler;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
126
331
20def3eaae8d Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 329
diff changeset
127 #define SIGNALMAX 17
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
128
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
129 /* 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
130 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
131 { _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
132 { _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
133 { _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
134 { _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
135 { _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
136 { _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
137 { _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
138 { _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
139 { _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
140 { _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
141 { _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
142 { _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
143 { _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
144 { _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
145 { _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
146 { _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
147 { _switch_page_event, DW_SIGNAL_SWITCH_PAGE }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
148 };
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
149
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
150 /* Alignment flags */
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
151 #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
152 #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
153 #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
154
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
155 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
156 {
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
157 #ifdef __sun__
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
158 /* 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
159 struct timespec req;
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
160
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
161 req.tv_sec = 0;
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
162 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
163
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
164 nanosleep(&req, NULL);
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
165 #else
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
166 usleep(period * 1000);
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
167 #endif
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
168 }
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
169
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
170 /* 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
171 static void *_findsigfunc(char *signame)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
172 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
173 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
174
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
175 for(z=0;z<SIGNALMAX;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
176 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
177 if(strcasecmp(signame, SignalTranslate[z].name) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
178 return SignalTranslate[z].func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
179 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
180 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
181 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
182
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
183 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
184 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
185 SignalHandler *work = (SignalHandler *)data;
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
186 int retval = FALSE;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
187
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
188 if(work)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
189 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
190 int (*setfocusfunc)(HWND, void *) = work->func;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
191
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
192 retval = setfocusfunc((HWND)window, work->data);
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
193 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
194 return retval;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
195 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
196
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
197 static gint _button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
198 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
199 SignalHandler *work = (SignalHandler *)data;
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
200 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
201
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
202 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
203 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
204 int (*buttonfunc)(HWND, int, int, int, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
205 int mybutton = event->button;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
206
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
207 if(event->button == 3)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
208 mybutton = 2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
209 else if(event->button == 2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
210 mybutton = 3;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
211
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
212 retval = buttonfunc(widget, event->x, event->y, mybutton, work->data);
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
213 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
214 return retval;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
215 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
216
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
217 static gint _button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
218 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
219 SignalHandler *work = (SignalHandler *)data;
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
220 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
221
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
222 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
223 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
224 int (*buttonfunc)(HWND, int, int, int, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
225 int mybutton = event->button;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
226
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
227 if(event->button == 3)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
228 mybutton = 2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
229 else if(event->button == 2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
230 mybutton = 3;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
231
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
232 retval = buttonfunc(widget, event->x, event->y, mybutton, work->data);
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
233 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
234 return retval;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
235 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
236
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
237 static gint _motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
238 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
239 SignalHandler *work = (SignalHandler *)data;
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
240 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
241
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
242 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
243 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
244 int (*motionfunc)(HWND, int, int, int, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
245 int keys = 0, x, y;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
246 GdkModifierType state;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
247
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
248 if (event->is_hint)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
249 gdk_window_get_pointer (event->window, &x, &y, &state);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
250 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
251 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
252 x = event->x;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
253 y = event->y;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
254 state = event->state;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
255 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
256
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
257 if (state & GDK_BUTTON1_MASK)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
258 keys = DW_BUTTON1_MASK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
259 if (state & GDK_BUTTON3_MASK)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
260 keys |= DW_BUTTON2_MASK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
261 if (state & GDK_BUTTON2_MASK)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
262 keys |= DW_BUTTON3_MASK;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
263
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
264 retval = motionfunc(widget, x, y, keys, work->data);
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
265 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
266 return retval;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
267 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
268
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
269 static gint _delete_event(GtkWidget *widget, GdkEvent *event, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
270 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
271 SignalHandler *work = (SignalHandler *)data;
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
272 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
273
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
274 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
275 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
276 int (*closefunc)(HWND, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
277
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
278 retval = closefunc(widget, work->data);
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
279 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
280 return retval;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
281 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
282
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
283 static gint _key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
284 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
285 SignalHandler *work = (SignalHandler *)data;
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
286 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
287
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
288 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
289 {
267
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
290 int (*keypressfunc)(HWND, char, int, int, void *) = work->func;
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
291
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
292 retval = keypressfunc(widget, *event->string, event->keyval,
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
293 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
294 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
295 return retval;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
296 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
297
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
298 static gint _generic_event(GtkWidget *widget, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
299 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
300 SignalHandler *work = (SignalHandler *)data;
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
301 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
302
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
303 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
304 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
305 int (*genericfunc)(HWND, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
306
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
307 retval = genericfunc(widget, work->data);
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
308 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
309 return retval;
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
310 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
311
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
312 static gint _activate_event(GtkWidget *widget, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
313 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
314 SignalHandler *work = (SignalHandler *)data;
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
315 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
316
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
317 if(work && !_dw_ignore_click)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
318 {
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
319 int (*activatefunc)(HWND, void *) = work->func;
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
320
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
321 retval = activatefunc(popup ? popup : work->window, work->data);
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
322 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
323 return retval;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
324 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
325
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
326 static gint _configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
327 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
328 SignalHandler *work = (SignalHandler *)data;
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
329 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
330
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
331 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
332 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
333 int (*sizefunc)(HWND, int, int, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
334
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
335 retval = sizefunc(widget, event->width, event->height, work->data);
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
336 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
337 return retval;
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
338 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
339
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
340 static gint _expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
341 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
342 SignalHandler *work = (SignalHandler *)data;
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
343 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
344
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
345 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
346 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
347 DWExpose exp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
348 int (*exposefunc)(HWND, DWExpose *, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
349
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
350 exp.x = event->area.x;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
351 exp.y = event->area.y;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
352 exp.width = event->area.width;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
353 exp.height = event->area.height;
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
354 retval = exposefunc(widget, &exp, work->data);
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
355 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
356 return retval;
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
357 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
358
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
359 static gint _item_select_event(GtkWidget *widget, GtkWidget *child, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
360 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
361 SignalHandler *work = (SignalHandler *)data;
39
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
362 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
363 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
364
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
365 if(_dw_recursing)
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
366 return FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
367
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
368 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
369 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
370 int (*selectfunc)(HWND, int, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
371 GList *list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
372 int item = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
373
39
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
374 _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
375
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
376 if(GTK_IS_COMBO(work->window))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
377 list = GTK_LIST(GTK_COMBO(work->window)->list)->children;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
378 else if(GTK_IS_LIST(widget))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
379 list = GTK_LIST(widget)->children;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
380 else
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
381 return FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
382
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
383 while(list)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
384 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
385 if(list->data == (gpointer)child)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
386 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
387 if(!gtk_object_get_data(GTK_OBJECT(work->window), "appending"))
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
388 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
389 gtk_object_set_data(GTK_OBJECT(work->window), "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
390 if(selectfunc)
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
391 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
392 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
393 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
394 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
395 item++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
396 list = list->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
397 }
39
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
398 _dw_recursing = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
399 }
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
400 return retval;
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
401 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
402
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
403 static gint _container_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
404 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
405 SignalHandler *work = (SignalHandler *)data;
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
406 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
407
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
408 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
409 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
410 if(event->button == 3)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
411 {
312
ff8f23594b15 Make sure itemdata is NULL for container callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 311
diff changeset
412 int (*contextfunc)(HWND, char *, int, int, void *, void *) = work->func;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
413 char *text;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
414 int row, col;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
415
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
416 gtk_clist_get_selection_info(GTK_CLIST(widget), event->x, event->y, &row, &col);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
417
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
418 text = (char *)gtk_clist_get_row_data(GTK_CLIST(widget), row);
312
ff8f23594b15 Make sure itemdata is NULL for container callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 311
diff changeset
419 retval = contextfunc(work->window, text, event->x, event->y, work->data, NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
420 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
421 }
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
422 return retval;
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
423 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
424
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
425 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
426 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
427 SignalHandler *work = (SignalHandler *)data;
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
428 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
429
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
430 if(work)
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
431 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
432 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
433 {
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
434 #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
435 int (*contextfunc)(HWND, char *, int, int, void *, void *) = work->func;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
436 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
437 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
438
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
439 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
440 {
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
441 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
442 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
443
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
444 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
445 {
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
446 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
447 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
448 }
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
449 }
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
450
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
451 retval = contextfunc(work->window, text, event->x, event->y, work->data, itemdata);
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
452 #else
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
453 int (*contextfunc)(HWND, char *, int, int, void *, void *) = work->func;
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
454 char *text = (char *)gtk_object_get_data(GTK_OBJECT(widget), "text");
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
455 void *itemdata = (void *)gtk_object_get_data(GTK_OBJECT(widget), "itemdata");
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
456
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
457 if(widget != work->window)
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
458 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
459 GtkWidget *tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(work->window));
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
460
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
461 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
462 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
463 GtkWidget *lastselect = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(tree), "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
464
c4e1139d9872 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 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
466 {
c4e1139d9872 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 text = (char *)gtk_object_get_data(GTK_OBJECT(lastselect), "text");
c4e1139d9872 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 itemdata = (void *)gtk_object_get_data(GTK_OBJECT(lastselect), "itemdata");
c4e1139d9872 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 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
470 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
471 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
472
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
473 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
474 #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
475 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
476 }
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
477 return retval;
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
478 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
479
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
480 #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
481 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
482 {
e0e73b4372a6 GTK 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 SignalHandler *work = (SignalHandler *)data;
e0e73b4372a6 GTK 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 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
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 if(work)
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
487 {
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
488 int (*treeselectfunc)(HWND, HTREEITEM, char *, 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
489 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
490 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
491 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
492 GtkWidget *item, *widget = (GtkWidget *)gtk_tree_selection_get_tree_view(sel);
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
493
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
494 if(widget && 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
495 {
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
496 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
497 gtk_tree_model_get(store, &iter, 0, &text, 2, &itemdata, 3, &item, -1);
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
498 retval = treeselectfunc(work->window, (HTREEITEM)item, text, 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
499 }
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
500 }
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
501 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
502 }
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
503 #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
504 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
505 {
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
506 SignalHandler *work = (SignalHandler *)data;
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
507 GtkWidget *treeroot = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(child), "tree");
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
508 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
509
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
510 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
511 {
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
512 GtkWidget *lastselect = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(treeroot), "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
513 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
514 gtk_tree_item_deselect(GTK_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
515 gtk_object_set_data(GTK_OBJECT(treeroot), "lastselect", (gpointer)child);
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
516 }
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
517
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
518 if(work)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
519 {
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
520 int (*treeselectfunc)(HWND, HTREEITEM, char *, void *, void *) = work->func;
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
521 char *text = (char *)gtk_object_get_data(GTK_OBJECT(child), "text");
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
522 void *itemdata = (void *)gtk_object_get_data(GTK_OBJECT(child), "itemdata");
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
523 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
524 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
525 return retval;
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
526 }
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 #endif
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
528
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
529 static gint _container_select_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
530 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
531 SignalHandler *work = (SignalHandler *)data;
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
532 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
533
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
534 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
535 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
536 if(event->button == 1 && event->type == GDK_2BUTTON_PRESS)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
537 {
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
538 int (*contextfunc)(HWND, char *, void *) = work->func;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
539 char *text;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
540 int row, col;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
541
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
542 gtk_clist_get_selection_info(GTK_CLIST(widget), event->x, event->y, &row, &col);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
543
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
544 text = (char *)gtk_clist_get_row_data(GTK_CLIST(widget), row);
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
545 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
546 gtk_object_set_data(GTK_OBJECT(widget), "_dw_double_click", (gpointer)1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
547 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
548 }
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
549 return retval;
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
550 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
551
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
552 /* 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
553 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
554 {
599644ca9064 Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 340
diff changeset
555 int 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
556 GtkWidget **pagearray = gtk_object_get_data(GTK_OBJECT(handle), "pagearray");
599644ca9064 Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 340
diff changeset
557 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
558
599644ca9064 Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 340
diff changeset
559 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
560 {
599644ca9064 Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 340
diff changeset
561 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
562 {
599644ca9064 Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 340
diff changeset
563 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
564 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
565 }
599644ca9064 Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 340
diff changeset
566 }
599644ca9064 Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 340
diff changeset
567 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
568 }
599644ca9064 Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 340
diff changeset
569
599644ca9064 Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 340
diff changeset
570
331
20def3eaae8d Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 329
diff changeset
571 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
572 {
20def3eaae8d Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 329
diff changeset
573 SignalHandler *work = (SignalHandler *)data;
20def3eaae8d Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 329
diff changeset
574 int retval = FALSE;
20def3eaae8d Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 329
diff changeset
575
20def3eaae8d Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 329
diff changeset
576 if(work)
20def3eaae8d Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 329
diff changeset
577 {
346
81fae15885d7 Implemented switch-page on OS/2, and changed the signal prototype to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 345
diff changeset
578 int (*switchpagefunc)(HWND, unsigned long, void *) = work->func;
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
579 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
580 }
20def3eaae8d Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 329
diff changeset
581 return retval;
20def3eaae8d Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 329
diff changeset
582 }
20def3eaae8d Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 329
diff changeset
583
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
584 static gint _select_row(GtkWidget *widget, gint row, gint column, GdkEventButton *event, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
585 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
586 GList *tmp = (GList *)gtk_object_get_data(GTK_OBJECT(widget), "selectlist");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
587 char *rowdata = gtk_clist_get_row_data(GTK_CLIST(widget), row);
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
588 int multi = (int)gtk_object_get_data(GTK_OBJECT(widget), "multi");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
589
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
590 if(rowdata)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
591 {
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
592 if(!multi)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
593 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
594 g_list_free(tmp);
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
595 tmp = NULL;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
596 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
597
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
598 tmp = g_list_append(tmp, rowdata);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
599 gtk_object_set_data(GTK_OBJECT(widget), "selectlist", tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
600 }
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
601 return FALSE;
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
602 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
603
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
604 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
605 {
d35771f70bdd Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 163
diff changeset
606 SignalHandler *work = (SignalHandler *)data;
d35771f70bdd Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 163
diff changeset
607 char *rowdata = gtk_clist_get_row_data(GTK_CLIST(widget), row);
311
24c1dfffe97e Unified the callback functions for tree and container widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 310
diff changeset
608 int (*contextfunc)(HWND, HWND, char *, void *, void *) = work->func;
24c1dfffe97e Unified the callback functions for tree and container widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 310
diff changeset
609
320
ae5b1eecea12 Don't send a DW_SIGNAL_ITEM_SELECT after DW_SIGNAL_ENTER.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 319
diff changeset
610 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
611 {
ae5b1eecea12 Don't send a DW_SIGNAL_ITEM_SELECT after DW_SIGNAL_ENTER.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 319
diff changeset
612 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
613 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
614 }
311
24c1dfffe97e Unified the callback functions for tree and container widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 310
diff changeset
615 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
616 }
d35771f70bdd Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 163
diff changeset
617
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
618 static gint _unselect_row(GtkWidget *widget, gint row, gint column, GdkEventButton *event, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
619 {
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
620 GList *tmp;
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 72
diff changeset
621 char *rowdata;
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 72
diff changeset
622
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 72
diff changeset
623 if(_dw_unselecting)
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
624 return FALSE;
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
625
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 72
diff changeset
626 tmp = (GList *)gtk_object_get_data(GTK_OBJECT(widget), "selectlist");
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 72
diff changeset
627 rowdata = gtk_clist_get_row_data(GTK_CLIST(widget), row);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
628
76
ce0f5528bab0 Fixed clist crashing problems on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 75
diff changeset
629 if(rowdata && tmp)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
630 {
76
ce0f5528bab0 Fixed clist crashing problems on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 75
diff changeset
631 tmp = g_list_remove(tmp, rowdata);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
632 gtk_object_set_data(GTK_OBJECT(widget), "selectlist", tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
633 }
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
634 return FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
635 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
636
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
637 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
638 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
639 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
640
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
641 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
642 newval++;
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
643
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
644 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
645 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
646
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
647 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
648 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
649 SignalHandler *work = (SignalHandler *)data;
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
650
208
5349a0735fda Hopefully fixed value_changed signal handler on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 205
diff changeset
651 if(work)
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
652 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
653 int (*valuechangedfunc)(HWND, int, void *) = work->func;
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
654 int max = _round_value(adjustment->upper);
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
655 int val = _round_value(adjustment->value);
208
5349a0735fda Hopefully fixed value_changed signal handler on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 205
diff changeset
656 GtkWidget *slider = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(adjustment), "slider");
5349a0735fda Hopefully fixed value_changed signal handler on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 205
diff changeset
657 GtkWidget *scrollbar = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(adjustment), "scrollbar");
5349a0735fda Hopefully fixed value_changed signal handler on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 205
diff changeset
658
5349a0735fda Hopefully fixed value_changed signal handler on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 205
diff changeset
659 if(slider)
63
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(GTK_IS_VSCALE(slider))
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
662 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
663 else
85
f5c651a36085 Fixed a bug in the value_changed callback when using a horizontal slider.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 84
diff changeset
664 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
665 }
208
5349a0735fda Hopefully fixed value_changed signal handler on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 205
diff changeset
666 else if(scrollbar)
5349a0735fda Hopefully fixed value_changed signal handler on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 205
diff changeset
667 {
5349a0735fda Hopefully fixed value_changed signal handler on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 205
diff changeset
668 valuechangedfunc(work->window, val, work->data);
5349a0735fda Hopefully fixed value_changed signal handler on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 205
diff changeset
669 }
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
670 }
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
671 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
672 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
673
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
674 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
675 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
676 GtkWidget *next = (GtkWidget *)data;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
677
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
678 if(next)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
679 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
680 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
681 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
682 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
683 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
684 else
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
685 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
686 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
687 }
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
688 return FALSE;
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
689 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
690
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
691 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
692 {
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
693 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
694 {
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
695 *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
696 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
697 *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
698 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
699 *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
700 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
701 }
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
702 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
703 }
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
704
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
705 static GdkPixmap *_find_pixmap(GdkBitmap **bitmap, long id, HWND handle, unsigned long *userwidth, unsigned long *userheight)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
706 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
707 char *data = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
708 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
709
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
710 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
711 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
712
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
713 for(z=0;z<_resources.resource_max;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
714 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
715 if(_resources.resource_id[z] == id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
716 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
717 data = _resources.resource_data[z];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
718 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
719 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
720 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
721
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
722 if(data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
723 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
724 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
725 #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
726 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
727
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
728 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
729 *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
730 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
731 *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
732
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
733 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
734 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
735 #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
736 gdk_imlib_data_to_pixmap((char **)data, &icon_pixmap, bitmap);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
737 #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
738 icon_pixmap = gdk_pixmap_create_from_xpm_d(handle->window, bitmap, &_colors[DW_CLR_PALEGRAY], (char **)data);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
739 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
740 return icon_pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
741 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
742 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
743 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
744
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
745 #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
746 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
747 {
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
748 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
749 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
750 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
751 }
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
752
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
753 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
754 {
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
755 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
756 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
757
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
758 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
759 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
760
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
761 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
762 {
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
763 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
764 {
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
765 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
766 break;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
767 }
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
768 }
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
769
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
770 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
771 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
772 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
773 }
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
774 #endif
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
775
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
776 static void _size_allocate(GtkWindow *window)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
777 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
778 XSizeHints sizehints;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
779
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
780 sizehints.base_width = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
781 sizehints.base_height = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
782 sizehints.width_inc = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
783 sizehints.height_inc = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
784 sizehints.min_width = 8;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
785 sizehints.min_height = 8;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
786
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
787 sizehints.flags = (PBaseSize|PMinSize|PResizeInc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
788
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
789 XSetWMNormalHints (GDK_DISPLAY(),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
790 GDK_WINDOW_XWINDOW (GTK_WIDGET (window)->window),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
791 &sizehints);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
792 gdk_flush ();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
793 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
794
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
795 /* 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
796 static int _find_thread_index(DWTID tid)
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
797 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
798 int z;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
799
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
800 for(z=0;z<DW_THREAD_LIMIT;z++)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
801 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
802 if(_dw_thread_list[z] == tid)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
803 return z;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
804 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
805 return 0;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
806 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
807
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
808 /* 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
809 static void _dw_thread_add(DWTID tid)
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
810 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
811 int z;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
812
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
813 for(z=0;z<DW_THREAD_LIMIT;z++)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
814 {
264
20becf7df38a Prevent duplicate thread IDs from getting added to the thread list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 259
diff changeset
815 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
816 return;
20becf7df38a Prevent duplicate thread IDs from getting added to the thread list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 259
diff changeset
817
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
818 if(_dw_thread_list[z] == (DWTID)-1)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
819 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
820 _dw_thread_list[z] = tid;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
821 _foreground[z].pixel = _foreground[z].red =_foreground[z].green = _foreground[z].blue = 0;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
822 _background[z].pixel = 0;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
823 _background[z].red = 0xaaaa;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
824 _background[z].green = 0xaaaa;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
825 _background[z].blue = 0xaaaa;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
826 return;
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 }
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
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
831 /* 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
832 static void _dw_thread_remove(DWTID tid)
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
833 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
834 int z;
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 for(z=0;z<DW_THREAD_LIMIT;z++)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
837 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
838 if(_dw_thread_list[z] == (DWTID)tid)
51
d97de82f0b6e Fix warning on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 49
diff changeset
839 _dw_thread_list[z] = (DWTID)-1;
48
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 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
842
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
843 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
844 * Initializes the Dynamic Windows engine.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
845 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
846 * newthread: True if this is the only thread.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
847 * False if there is already a message loop running.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
848 */
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
849 int dw_int_init(DWResources *res, int newthread, int *argc, char **argv[])
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
850 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
851 int z;
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
852 char *tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
853
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
854 if(res)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
855 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
856 _resources.resource_max = res->resource_max;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
857 _resources.resource_id = res->resource_id;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
858 _resources.resource_data = res->resource_data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
859 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
860 gtk_set_locale();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
861 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
862 #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
863 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
864 #endif
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
865
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
866 gtk_init(argc, argv);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
867 #ifdef USE_IMLIB
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
868 gdk_imlib_init();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
869 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
870 /* Add colors to the system colormap */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
871 _dw_cmap = gdk_colormap_get_system();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
872 for(z=0;z<16;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
873 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
874
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
875 tmp = getenv("DW_BORDER_WIDTH");
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
876 if(tmp)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
877 _dw_border_width = atoi(tmp);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
878 tmp = getenv("DW_BORDER_HEIGHT");
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
879 if(tmp)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
880 _dw_border_height = atoi(tmp);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
881
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
882 for(z=0;z<DW_THREAD_LIMIT;z++)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
883 _dw_thread_list[z] = (DWTID)-1;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
884
77
002da4d18ac6 Set tooltip background color to yellow.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 76
diff changeset
885 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
886
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
887 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
888 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
889
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
890 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
891 * 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
892 */
2a0d7b57a6da Removed unnecessary parameters from dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 149
diff changeset
893 void dw_main(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
894 {
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
895 gdk_threads_enter();
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
896 _dw_thread = pthread_self();
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
897 _dw_thread_add(_dw_thread);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
898 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
899 _dw_thread = (pthread_t)-1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
900 gdk_threads_leave();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
901 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
902
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
903 /*
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
904 * 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
905 * 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
906 * 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
907 */
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
908 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
909 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
910 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
911 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
912
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
913 gettimeofday(&start, NULL);
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
914
340
eff674cb4935 Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 338
diff changeset
915 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
916 {
eff674cb4935 Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 338
diff changeset
917 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
918
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
919 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
920
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
921 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
922 {
340
eff674cb4935 Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 338
diff changeset
923 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
924 {
eff674cb4935 Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 338
diff changeset
925 gdk_threads_enter();
eff674cb4935 Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 338
diff changeset
926 _dw_thread = curr;
eff674cb4935 Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 338
diff changeset
927 }
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
928 if(gtk_events_pending())
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
929 gtk_main_iteration();
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
930 else
237
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
931 _dw_msleep(1);
340
eff674cb4935 Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 338
diff changeset
932 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
933 {
eff674cb4935 Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 338
diff changeset
934 _dw_thread = orig;
eff674cb4935 Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 338
diff changeset
935 gdk_threads_leave();
eff674cb4935 Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 338
diff changeset
936 }
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
937 gettimeofday(&tv, NULL);
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
938 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
939 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
940 else
237
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
941 _dw_msleep(milliseconds);
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
942 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
943
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
944 /*
205
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
945 * 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
946 */
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
947 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
948 {
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
949 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
950 _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
951 _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
952 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
953 _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
954 gdk_threads_leave();
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
955 }
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
956
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
957 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
958 * Free's memory allocated by dynamic windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
959 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
960 * ptr: Pointer to dynamic windows allocated
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
961 * memory to be free()'d.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
962 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
963 void dw_free(void *ptr)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
964 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
965 free(ptr);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
966 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
967
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
968 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
969 * Allocates and initializes a dialog struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
970 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
971 * data: User defined data to be passed to functions.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
972 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
973 DWDialog *dw_dialog_new(void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
974 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
975 DWDialog *tmp = malloc(sizeof(DWDialog));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
976
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
977 tmp->eve = dw_event_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
978 dw_event_reset(tmp->eve);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
979 tmp->data = data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
980 tmp->done = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
981 tmp->result = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
982
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
983 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
984 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
985
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
986 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
987 * Accepts a dialog struct and returns the given data to the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
988 * initial called of dw_dialog_wait().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
989 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
990 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
991 * result: Data to be returned by dw_dialog_wait().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
992 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
993 int dw_dialog_dismiss(DWDialog *dialog, void *result)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
994 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
995 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
996 if(pthread_self() == _dw_thread || _dw_thread == (pthread_t)-1)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
997 gtk_main_quit();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
998 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
999 dw_event_post(dialog->eve);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1000 dialog->done = TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1001 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1002 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1003
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1004 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1005 * Accepts a dialog struct waits for dw_dialog_dismiss() to be
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1006 * called by a signal handler with the given dialog struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1007 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1008 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1009 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1010 void *dw_dialog_wait(DWDialog *dialog)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1011 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1012 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
1013 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
1014
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
1015 /* _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
1016 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
1017 {
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
1018 _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
1019 newprocess = 1;
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
1020 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
1021 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1022
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1023 if(pthread_self() == _dw_thread)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1024 gtk_main();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1025 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1026 dw_event_wait(dialog->eve, -1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1027
41
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
1028 if(newprocess)
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
1029 {
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
1030 _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
1031 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
1032 }
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
1033
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1034 dw_event_close(&dialog->eve);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1035 tmp = dialog->result;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1036 free(dialog);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1037 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1038 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1039
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1040 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
1041 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1042 DWDialog *dwwait = (DWDialog *)data;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1043
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1044 if(!dwwait)
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
1045 return FALSE;
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1046
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1047 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
1048 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
1049 return FALSE;
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1050 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1051
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1052 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1053 * Displays a Message Box with given text and title..
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1054 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1055 * title: The title of the message box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1056 * format: printf style format string.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1057 * ...: Additional variables for use in the format.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1058 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1059 int dw_messagebox(char *title, char *format, ...)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1060 {
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1061 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
1062 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
1063 DWDialog *dwwait;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1064 va_list args;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1065 char outbuf[256];
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1066 int x, y;
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1067
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1068 va_start(args, format);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1069 vsprintf(outbuf, format, args);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1070 va_end(args);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1071
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1072 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
1073 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
1074 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
1075
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1076 /* Archive Name */
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1077 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
1078 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
1079
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1080 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
1081
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1082 /* 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
1083 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
1084
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1085 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
1086
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1087 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
1088
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1089 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
1090
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1091 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
1092
307
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
1093 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
1094
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1095 x = (dw_screen_width() - 220)/2;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1096 y = (dw_screen_height() - 110)/2;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1097
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1098 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
1099
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1100 dw_window_show(entrywindow);
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1101
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1102 dw_dialog_wait(dwwait);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1103
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1104 return strlen(outbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1105 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1106
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
1107 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
1108 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1109 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
1110
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1111 if(!dwwait)
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
1112 return FALSE;
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1113
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1114 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
1115 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
1116 return FALSE;
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
1117 }
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
1118
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
1119 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
1120 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1121 DWDialog *dwwait = (DWDialog *)data;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1122
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1123 if(!dwwait)
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
1124 return FALSE;
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1125
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1126 dw_window_destroy((HWND)dwwait->data);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1127 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
1128 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
1129 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1130
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1131 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1132 * Displays a Message Box with given text and title..
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1133 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1134 * title: The title of the message box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1135 * text: The text to display in the box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1136 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1137 * True if YES False of NO.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1138 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1139 int dw_yesno(char *title, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1140 {
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1141 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
1142 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
1143 DWDialog *dwwait;
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1144 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
1145
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1146 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
1147
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
1148 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
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 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
1151
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1152 /* 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
1153 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
1154 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
1155
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1156 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
1157
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1158 /* 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
1159 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
1160
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1161 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
1162
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1163 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
1164
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1165 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
1166
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1167 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
1168
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1169 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
1170
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1171 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
1172
307
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
1173 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
1174 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
1175
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1176 x = (dw_screen_width() - 220)/2;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1177 y = (dw_screen_height() - 110)/2;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1178
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1179 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
1180
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1181 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
1182
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1183 return (int)dw_dialog_wait(dwwait);;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1184 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1185
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1186 /*
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1187 * 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
1188 * Parameters:
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1189 * handle: The window handle to minimize.
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1190 */
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1191 int dw_window_minimize(HWND handle)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1192 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1193 int _locked_by_me = FALSE;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1194
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1195 if(!handle)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1196 return 0;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1197
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1198 DW_MUTEX_LOCK;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1199 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
1200 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
1201 DefaultScreen (GDK_DISPLAY ()));
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1202 DW_MUTEX_UNLOCK;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1203 return 0;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1204 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1205
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1206 /*
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1207 * Makes the window topmost.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1208 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1209 * 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
1210 */
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1211 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
1212 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1213 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
1214
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1215 if(!handle)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1216 return 0;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1217
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1218 DW_MUTEX_LOCK;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1219 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
1220 DW_MUTEX_UNLOCK;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1221 return 0;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1222 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1223
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1224 /*
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1225 * Makes the window bottommost.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1226 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1227 * 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
1228 */
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1229 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
1230 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1231 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
1232
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1233 if(!handle)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1234 return 0;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1235
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1236 DW_MUTEX_LOCK;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1237 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
1238 DW_MUTEX_UNLOCK;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1239 return 0;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1240 }
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 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1243 * Makes the window visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1244 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1245 * handle: The window handle to make visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1246 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1247 int dw_window_show(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1248 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1249 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
1250 GtkWidget *defaultitem;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1251
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1252 if(!handle)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1253 return 0;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1254
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1255 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1256 gtk_widget_show(handle);
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1257 if(GTK_WIDGET(handle)->window)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1258 {
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
1259 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
1260 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
1261
49ac97060328 Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 271
diff changeset
1262 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
1263 {
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
1264 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
1265 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
1266 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
1267 }
49ac97060328 Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 271
diff changeset
1268
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1269 gdk_window_raise(GTK_WIDGET(handle)->window);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1270 gdk_flush();
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1271 gdk_window_show(GTK_WIDGET(handle)->window);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1272 gdk_flush();
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1273 }
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
1274 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
1275 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
1276 gtk_widget_grab_focus(defaultitem);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1277 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1278 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1279 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1280
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1281 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1282 * Makes the window invisible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1283 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1284 * handle: The window handle to make visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1285 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1286 int dw_window_hide(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1287 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1288 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1289
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1290 if(!handle)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1291 return 0;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1292
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1293 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1294 gtk_widget_hide(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1295 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1296 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1297 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1298
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1299 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1300 * Destroys a window and all of it's children.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1301 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1302 * handle: The window handle to destroy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1303 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1304 int dw_window_destroy(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1305 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1306 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1307
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1308 if(!handle)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1309 return 0;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1310
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1311 DW_MUTEX_LOCK;
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
1312 if(GTK_IS_WIDGET(handle))
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
1313 gtk_widget_destroy(handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1314 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1315 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1316 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1317
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
1318 /* 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
1319 * 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
1320 * 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
1321 */
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1322 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
1323 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1324 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1325
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1326 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1327 * Changes a window's parent to newparent.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1328 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1329 * handle: The window handle to destroy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1330 * newparent: The window's new parent window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1331 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1332 void dw_window_reparent(HWND handle, HWND newparent)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1333 {
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1334 int _locked_by_me = FALSE;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1335
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1336 DW_MUTEX_LOCK;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1337 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
1338 DW_MUTEX_UNLOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1339 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1340
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1341 static int _set_font(HWND handle, char *fontname)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1342 {
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
1343 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
1344 #if GTK_MAJOR_VERSION < 2
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1345 GtkStyle *style;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1346 GdkFont *font = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1347
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1348 font = gdk_font_load(fontname);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1349
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1350 if(font)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1351 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1352 style = gtk_widget_get_style(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1353 style->font = font;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1354 gtk_widget_set_style(handle, style);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1355 retval = TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1356 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
1357 #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
1358 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
1359
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
1360 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
1361 {
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
1362 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
1363 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
1364 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
1365 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1366 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1367 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1368
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1369 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1370 * Sets the font used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1371 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1372 * handle: The window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1373 * fontname: Name and size of the font in the form "size.fontname"
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1374 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1375 int dw_window_set_font(HWND handle, char *fontname)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1376 {
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
1377 #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
1378 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
1379 #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
1380 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
1381 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1382 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1383 char *font;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1384 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1385 gpointer data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1386
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1387 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1388 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1389 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1390 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1391 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1392 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1393 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1394 font = strdup(fontname);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1395
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
1396 #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
1397 /* Free old font if it exists */
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1398 gdkfont = (GdkFont *)gtk_object_get_data(GTK_OBJECT(handle2), "gdkfont");
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1399 if(gdkfont)
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1400 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
1401 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
1402 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
1403 gdkfont = gdk_font_load("fixed");
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1404 gtk_object_set_data(GTK_OBJECT(handle2), "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
1405 #endif
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1406
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1407 /* Free old font name if one is allocated */
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1408 data = gtk_object_get_data(GTK_OBJECT(handle2), "fontname");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1409 if(data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1410 free(data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1411
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
1412 gtk_object_set_data(GTK_OBJECT(handle2), "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
1413 #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
1414 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
1415
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
1416 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
1417 {
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
1418 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
1419 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
1420 }
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
1421 #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
1422 DW_MUTEX_UNLOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1423 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1424 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1425
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1426 void _free_gdk_colors(HWND handle)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1427 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1428 GdkColor *old = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle), "foregdk");
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1429
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1430 if(old)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1431 free(old);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1432
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1433 old = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle), "backgdk");
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1434
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1435 if(old)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1436 free(old);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1437 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1438
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1439 /* 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
1440 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
1441 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1442 GdkColor *foregdk = malloc(sizeof(GdkColor));
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1443 GdkColor *backgdk = malloc(sizeof(GdkColor));
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1444
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1445 _free_gdk_colors(handle);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1446
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1447 *foregdk = fore;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1448 *backgdk = back;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1449
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1450 gtk_object_set_data(GTK_OBJECT(handle), "foregdk", (gpointer)foregdk);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1451 gtk_object_set_data(GTK_OBJECT(handle), "backgdk", (gpointer)backgdk);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1452 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1453
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1454 static int _set_color(HWND handle, unsigned long fore, unsigned long back)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1455 {
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1456 /* 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
1457 * 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
1458 */
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1459 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
1460 #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
1461 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
1462 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1463
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1464 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
1465 {
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1466 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
1467 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
1468 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
1469 forecolor.blue = DW_BLUE_VALUE(fore) << 8;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1470
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1471 gdk_color_alloc(_dw_cmap, &forecolor);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1472
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1473 #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
1474 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
1475 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
1476 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
1477 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
1478 #else
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1479 if(style)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1480 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
1481 #endif
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1482 }
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1483 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
1484 {
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1485 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
1486
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1487 #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
1488 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
1489 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
1490 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
1491 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
1492 #else
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1493 if(style)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1494 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
1495 #endif
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1496 }
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1497 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
1498 {
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1499 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
1500 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
1501 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
1502 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
1503
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1504 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
1505
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1506 #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
1507 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
1508 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
1509 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
1510 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
1511 #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
1512 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
1513 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
1514 #endif
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1515 }
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1516 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
1517 {
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1518 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
1519
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
1520 #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
1521 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
1522 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
1523 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
1524 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
1525 #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
1526 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
1527 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
1528 #endif
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1529 }
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 _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
1532
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1533 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
1534 {
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1535 int z, rowcount = (int)gtk_object_get_data(GTK_OBJECT(handle), "rowcount");
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1536
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1537 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
1538 {
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1539 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
1540 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
1541 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1542 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1543
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1544 #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
1545 if(style)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1546 {
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1547 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
1548 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
1549 }
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1550 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1551 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1552 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1553 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1554 * Sets the colors used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1555 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1556 * handle: The window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1557 * fore: Foreground color in RGB format.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1558 * back: Background color in RGB format.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1559 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1560 int dw_window_set_color(HWND handle, unsigned long fore, unsigned long back)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1561 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1562 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1563 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1564
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1565 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1566
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
1567 if(GTK_IS_SCROLLED_WINDOW(handle) || GTK_IS_BOX(handle))
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1568 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1569 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1570 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1571 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1572 }
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1573 else if(GTK_IS_TABLE(handle))
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1574 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1575 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "eventbox");
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1576 if(tmp)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1577 handle2 = tmp;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1578 }
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1579
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1580 _set_color(handle2, fore, back);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1581
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1582 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1583 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1584 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1585
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1586 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1587 * Sets the font used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1588 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1589 * handle: The window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1590 * border: Size of the window border in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1591 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1592 int dw_window_set_border(HWND handle, int border)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1593 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1594 /* TODO */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1595 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1596 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1597
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1598 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1599 * Captures the mouse input to this window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1600 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1601 * handle: Handle to receive mouse input.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1602 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1603 void dw_window_capture(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1604 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1605 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1606
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1607 DW_MUTEX_LOCK;
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1608 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
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1609 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1610 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1611
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1612 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1613 * 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
1614 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1615 * 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
1616 * 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
1617 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1618 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
1619 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
1620 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
1621 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
1622
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
1623 DW_MUTEX_LOCK;
337
e9a424e641ff Some pointer changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 331
diff changeset
1624 if(pointertype & (1 << 31))
e9a424e641ff Some pointer changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 331
diff changeset
1625 {
e9a424e641ff Some pointer changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 331
diff changeset
1626 GdkBitmap *bitmap = NULL;
338
44e2bdacd8f3 Minor fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 337
diff changeset
1627 GdkPixmap *pixmap = _find_private_pixmap(&bitmap, (pointertype & 0xFFFFFF), NULL, NULL);
44e2bdacd8f3 Minor fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 337
diff changeset
1628 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
1629 }
e9a424e641ff Some pointer changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 331
diff changeset
1630 else
e9a424e641ff Some pointer changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 331
diff changeset
1631 cursor = gdk_cursor_new(pointertype);
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1632 if(handle && handle->window)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1633 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
1634 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
1635 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
1636 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1637
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1638 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1639 * Releases previous mouse capture.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1640 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1641 void dw_window_release(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1642 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1643 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1644
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1645 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1646 gdk_pointer_ungrab(GDK_CURRENT_TIME);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1647 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1648 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1649
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1650 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1651 * Create a new Window Frame.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1652 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1653 * owner: The Owner's window handle or HWND_DESKTOP.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1654 * title: The Window title.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1655 * flStyle: Style flags, see the PM reference.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1656 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1657 HWND dw_window_new(HWND hwndOwner, char *title, unsigned long flStyle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1658 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1659 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1660 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
1661 int flags = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1662
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1663 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
1664 last_window = tmp = gtk_window_new(GTK_WINDOW_TOPLEVEL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1665
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1666 gtk_window_set_title(GTK_WINDOW(tmp), title);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1667 if(!(flStyle & DW_FCF_SIZEBORDER))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1668 gtk_window_set_policy(GTK_WINDOW(tmp), FALSE, FALSE, TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1669
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1670 gtk_widget_realize(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1671
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1672 if(flStyle & DW_FCF_TITLEBAR)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1673 flags |= GDK_DECOR_TITLE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1674
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1675 if(flStyle & DW_FCF_MINMAX)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1676 flags |= GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1677
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1678 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
1679 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
1680
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
1681 if(flStyle & DW_FCF_BORDER || flStyle & DW_FCF_DLGBORDER)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1682 flags |= GDK_DECOR_BORDER;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1683
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1684 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
1685
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1686 if(hwndOwner)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1687 gdk_window_reparent(GTK_WIDGET(tmp)->window, GTK_WIDGET(hwndOwner)->window, 0, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1688
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
1689 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
1690 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
1691
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1692 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1693 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1694 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1695
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1696 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1697 * Create a new Box to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1698 * 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
1699 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1700 * pad: Number of pixels to pad around the box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1701 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1702 HWND dw_box_new(int type, int pad)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1703 {
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1704 GtkWidget *tmp, *eventbox;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1705 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1706
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1707 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
1708 tmp = gtk_table_new(1, 1, FALSE);
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1709 eventbox = gtk_event_box_new();
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1710
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1711 gtk_widget_show(eventbox);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1712 gtk_object_set_data(GTK_OBJECT(tmp), "eventbox", (gpointer)eventbox);
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1713 gtk_object_set_data(GTK_OBJECT(tmp), "boxtype", (gpointer)type);
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1714 gtk_object_set_data(GTK_OBJECT(tmp), "boxpad", (gpointer)pad);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1715 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1716 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1717 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1718 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1719
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1720 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1721 * Create a new Group Box to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1722 * 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
1723 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1724 * pad: Number of pixels to pad around the box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1725 * title: Text to be displayined in the group outline.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1726 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1727 HWND dw_groupbox_new(int type, int pad, char *title)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1728 {
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1729 GtkWidget *tmp, *frame;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1730 int _locked_by_me = FALSE;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1731
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1732 DW_MUTEX_LOCK;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1733 frame = gtk_frame_new(NULL);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1734 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
1735 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
1736 tmp = gtk_table_new(1, 1, FALSE);
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1737 gtk_container_border_width(GTK_CONTAINER(tmp), pad);
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1738 gtk_object_set_data(GTK_OBJECT(tmp), "boxtype", (gpointer)type);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1739 gtk_object_set_data(GTK_OBJECT(tmp), "boxpad", (gpointer)pad);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1740 gtk_object_set_data(GTK_OBJECT(frame), "boxhandle", (gpointer)tmp);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1741 gtk_container_add(GTK_CONTAINER(frame), tmp);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1742 gtk_widget_show(tmp);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1743 gtk_widget_show(frame);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1744 DW_MUTEX_UNLOCK;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1745 return frame;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1746 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1747
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1748 /*
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1749 * 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
1750 * Parameters:
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1751 * 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
1752 */
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1753 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
1754 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
1755 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
1756 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
1757
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
1758 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
1759 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
1760 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
1761 return tmp;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1762 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1763
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1764 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1765 * Create a bitmap object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1766 * 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
1767 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1768 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1769 HWND dw_bitmap_new(unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1770 {
121
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
1771 #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
1772 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
1773 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
1774 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
1775 "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
1776 " 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
1777 ". 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
1778 "."};
121
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
1779 #endif
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
1780 GtkWidget *tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1781 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1782
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1783 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
1784 #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
1785 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
1786 #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
1787 gdk_imlib_data_to_pixmap(test_xpm, &pixmap, &bitmap);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1788 #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
1789 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
1790
997e9ed670ef Fixes for box alignment problem on OS/2, crash in dw_bitmap_new() on unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 46
diff changeset
1791 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
1792 pixmap = gdk_pixmap_create_from_xpm_d(last_window->window, &bitmap, &_colors[DW_CLR_PALEGRAY], test_xpm);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1793 #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
1794 #if GTK_MAJOR_VERSION < 2
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1795 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
1796 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1797 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1798 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1799 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1800 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1801 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1802
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1803 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1804 * Create a notebook object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1805 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1806 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1807 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1808 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1809 HWND dw_notebook_new(unsigned long id, int top)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1810 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
1811 GtkWidget *tmp, **pagearray = calloc(sizeof(GtkWidget *), 256);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1812 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1813
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1814 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1815 tmp = gtk_notebook_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1816 if(top)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1817 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(tmp), GTK_POS_TOP);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1818 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1819 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
1820 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
1821 #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
1822 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
1823 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1824 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1825 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
1826 gtk_object_set_data(GTK_OBJECT(tmp), "pagearray", (gpointer)pagearray);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1827 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1828 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1829 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1830
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1831 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1832 * Create a menu object to be popped up.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1833 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1834 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1835 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1836 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1837 HMENUI dw_menu_new(unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1838 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1839 int _locked_by_me = FALSE;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1840 GtkAccelGroup *accel_group;
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1841 HMENUI tmp;
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1842
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1843 DW_MUTEX_LOCK;
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1844 tmp = gtk_menu_new();
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1845 gtk_widget_show(tmp);
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1846 accel_group = gtk_accel_group_new();
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1847 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1848 gtk_object_set_data(GTK_OBJECT(tmp), "accel", (gpointer)accel_group);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1849 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1850 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1851 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1852
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1853 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1854 * Create a menubar on a window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1855 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1856 * location: Handle of a window frame to be attached to.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1857 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1858 HMENUI dw_menubar_new(HWND location)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1859 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1860 GtkWidget *box;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1861 int _locked_by_me = FALSE;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1862 GtkAccelGroup *accel_group;
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1863 HMENUI tmp;
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1864
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1865 DW_MUTEX_LOCK;
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1866 tmp = gtk_menu_bar_new();
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1867 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
1868 gtk_widget_show(tmp);
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1869 accel_group = gtk_accel_group_new();
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1870 gtk_object_set_data(GTK_OBJECT(tmp), "accel", (gpointer)accel_group);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1871
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1872 if(box)
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1873 gtk_box_pack_end(GTK_BOX(box), tmp, FALSE, FALSE, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1874
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1875 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1876 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1877 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1878
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1879 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1880 * Destroys a menu created with dw_menubar_new or dw_menu_new.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1881 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1882 * menu: Handle of a menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1883 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1884 void dw_menu_destroy(HMENUI *menu)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1885 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1886 if(menu && *menu)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1887 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1888 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1889
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1890 DW_MUTEX_LOCK;
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1891 gtk_widget_destroy(*menu);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1892 *menu = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1893 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1894 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1895 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1896
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1897 char _removetilde(char *dest, char *src)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1898 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1899 int z, cur=0;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1900 char accel = '\0';
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1901
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1902 for(z=0;z<strlen(src);z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1903 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1904 if(src[z] != '~')
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1905 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1906 dest[cur] = src[z];
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1907 cur++;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1908 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1909 else
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1910 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1911 dest[cur] = '_';
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1912 accel = src[z+1];
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1913 cur++;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1914 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1915 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1916 dest[cur] = 0;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1917 return accel;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1918 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1919
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1920 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1921 * Adds a menuitem or submenu to an existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1922 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1923 * menu: The handle the the existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1924 * title: The title text on the menu item to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1925 * id: An ID to be used for message passing.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1926 * flags: Extended attributes to set on the menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1927 * end: If TRUE memu is positioned at the end of the menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1928 * check: If TRUE menu is "check"able.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1929 * submenu: Handle to an existing menu to be a submenu or NULL.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1930 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1931 HWND dw_menu_append_item(HMENUI menu, char *title, unsigned long id, unsigned long flags, int end, int check, HMENUI submenu)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1932 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1933 GtkWidget *tmphandle;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1934 char accel, *tempbuf = malloc(strlen(title)+1);
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1935 int _locked_by_me = FALSE, submenucount;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1936 guint tmp_key;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1937 GtkAccelGroup *accel_group;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1938
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1939 if(!menu)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1940 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1941 free(tempbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1942 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1943 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1944
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1945 DW_MUTEX_LOCK;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1946 accel = _removetilde(tempbuf, title);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1947
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1948 accel_group = (GtkAccelGroup *)gtk_object_get_data(GTK_OBJECT(menu), "accel");
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1949 submenucount = (int)gtk_object_get_data(GTK_OBJECT(menu), "submenucount");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1950
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1951 if(strlen(tempbuf) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1952 tmphandle=gtk_menu_item_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1953 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1954 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1955 if(check)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1956 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1957 char numbuf[10];
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1958 if(accel && accel_group)
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1959 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1960 tmphandle=gtk_check_menu_item_new_with_label("");
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1961 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
1962 #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
1963 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
1964 #endif
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1965 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1966 else
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1967 tmphandle=gtk_check_menu_item_new_with_label(tempbuf);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1968 gtk_check_menu_item_set_show_toggle(GTK_CHECK_MENU_ITEM(tmphandle), TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1969 sprintf(numbuf, "%lu", id);
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1970 gtk_object_set_data(GTK_OBJECT(menu), numbuf, (gpointer)tmphandle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1971 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1972 else
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1973 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1974 if(accel && accel_group)
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1975 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1976 tmphandle=gtk_menu_item_new_with_label("");
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1977 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
1978 #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
1979 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
1980 #endif
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1981 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1982 else
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1983 tmphandle=gtk_menu_item_new_with_label(tempbuf);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1984 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1985 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1986
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1987 gtk_widget_show(tmphandle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1988
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1989 if(submenu)
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1990 {
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1991 char tempbuf[100];
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1992
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1993 sprintf(tempbuf, "submenu%d", submenucount);
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1994 submenucount++;
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1995 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
1996 gtk_object_set_data(GTK_OBJECT(menu), tempbuf, (gpointer)submenu);
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1997 gtk_object_set_data(GTK_OBJECT(menu), "submenucount", (gpointer)submenucount);
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1998 }
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1999
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
2000 if(GTK_IS_MENU_BAR(menu))
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
2001 gtk_menu_bar_append(GTK_MENU_BAR(menu), tmphandle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2002 else
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
2003 gtk_menu_append(GTK_MENU(menu), tmphandle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2004
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2005 gtk_object_set_data(GTK_OBJECT(tmphandle), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2006 free(tempbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2007 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2008 return tmphandle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2009 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2010
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2011 GtkWidget *_find_submenu_id(GtkWidget *start, char *name)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2012 {
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2013 GtkWidget *tmp;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2014 int z, submenucount = (int)gtk_object_get_data(GTK_OBJECT(start), "submenucount");
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2015
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2016 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
2017 return tmp;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2018
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2019 for(z=0;z<submenucount;z++)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2020 {
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2021 char tempbuf[100];
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2022 GtkWidget *submenu, *menuitem;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2023
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2024 sprintf(tempbuf, "submenu%d", z);
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2025
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2026 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
2027 {
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2028 if((menuitem = _find_submenu_id(submenu, name)))
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2029 return menuitem;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2030 }
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2031 }
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2032 return NULL;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2033 }
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2034
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2035 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2036 * Sets the state of a menu item check.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2037 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2038 * menu: The handle the the existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2039 * id: Menuitem id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2040 * check: TRUE for checked FALSE for not checked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2041 */
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2042 void dw_menu_item_set_check(HMENUI menu, unsigned long id, int check)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2043 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2044 char numbuf[10];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2045 GtkWidget *tmphandle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2046 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2047
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
2048 if(!menu)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2049 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2050
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2051 DW_MUTEX_LOCK;
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2052 sprintf(numbuf, "%lu", id);
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
2053 tmphandle = _find_submenu_id(menu, numbuf);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2054
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2055 if(tmphandle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2056 {
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2057 _dw_ignore_click = 1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2058 if(GTK_CHECK_MENU_ITEM(tmphandle)->active != check)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2059 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
2060 _dw_ignore_click = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2061 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2062 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2063 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2064
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2065 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2066 * Pops up a context menu at given x and y coordinates.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2067 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2068 * menu: The handle the the existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2069 * parent: Handle to the window initiating the popup.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2070 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2071 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2072 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2073 void dw_menu_popup(HMENUI *menu, HWND parent, int x, int y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2074 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2075 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2076
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2077 if(!menu || !*menu)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2078 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2079
93
98cce029a611 Changed handling of menu item click events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 92
diff changeset
2080 popup = parent;
98cce029a611 Changed handling of menu item click events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 92
diff changeset
2081
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2082 DW_MUTEX_LOCK;
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
2083 gtk_menu_popup(GTK_MENU(*menu), NULL, NULL, NULL, NULL, 1, GDK_CURRENT_TIME);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2084 *menu = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2085 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2086 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2087
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2088
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2089 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2090 * Returns the current X and Y coordinates of the mouse pointer.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2091 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2092 * x: Pointer to variable to store X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2093 * y: Pointer to variable to store Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2094 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2095 void dw_pointer_query_pos(long *x, long *y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2096 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2097 GdkModifierType state;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2098 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
2099 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
2100
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
2101 DW_MUTEX_LOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2102 gdk_window_get_pointer (GDK_ROOT_PARENT(), &gx, &gy, &state);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2103 *x = gx;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2104 *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
2105 DW_MUTEX_UNLOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2106 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2107
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2108 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2109 * Sets the X and Y coordinates of the mouse pointer.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2110 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2111 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2112 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2113 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2114 void dw_pointer_set_pos(long x, long y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2115 {
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
2116 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
2117
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
2118 DW_MUTEX_LOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2119 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
2120 DW_MUTEX_UNLOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2121 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2122
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2123 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2124 * Create a container object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2125 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2126 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2127 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2128 */
350
2216e65ad2ae Removed slider flags and container selection flags from the header file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 346
diff changeset
2129 HWND dw_container_new(unsigned long id, int multi)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2130 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2131 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2132 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2133
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2134 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2135 tmp = gtk_scrolled_window_new (NULL, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2136 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (tmp),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2137 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2138
350
2216e65ad2ae Removed slider flags and container selection flags from the header file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 346
diff changeset
2139 gtk_object_set_data(GTK_OBJECT(tmp), "multi", (gpointer)multi);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2140 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2141 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2142
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2143 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2144 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2145 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2146
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2147 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2148 * 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
2149 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2150 * 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
2151 * 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
2152 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2153 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
2154 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2155 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
2156 #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
2157 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
2158 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
2159 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
2160 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
2161 #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
2162 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
2163
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2164 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
2165 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
2166 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
2167 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
2168
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2169 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2170 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
2171 #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
2172 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
2173 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
2174 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
2175 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
2176
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2177 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
2178 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
2179 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
2180 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
2181 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
2182 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
2183
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2184 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
2185 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
2186 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
2187
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
2188 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
2189 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
2190 #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
2191 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
2192 #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
2193 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
2194 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2195 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
2196 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
2197 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
2198 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2199 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
2200 #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
2201 /* 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
2202 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
2203 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
2204 #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
2205
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2206 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
2207 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
2208
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2209 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
2210 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
2211 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2212
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2213
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2214 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2215 * Create a new static text window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2216 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2217 * 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
2218 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2219 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2220 HWND dw_text_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2221 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2222 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2223 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2224
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2225 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2226 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
2227
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2228 /* 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
2229 gtk_misc_set_alignment(GTK_MISC(tmp), 0.0f, 0.5f);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2230 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2231 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
2232 gtk_misc_set_alignment(GTK_MISC(tmp), DW_LEFT, DW_LEFT);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2233 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2234 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2235 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2236
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2237 /*
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2238 * 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
2239 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2240 * 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
2241 * 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
2242 */
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2243 HWND dw_status_text_new(char *text, ULONG id)
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2244 {
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2245 GtkWidget *tmp, *frame;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2246 int _locked_by_me = FALSE;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2247
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2248 DW_MUTEX_LOCK;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2249 frame = gtk_frame_new(NULL);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2250 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
2251 tmp = gtk_label_new(text);
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2252 gtk_container_add(GTK_CONTAINER(frame), tmp);
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2253 gtk_widget_show(tmp);
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2254 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
2255
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2256 /* 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
2257 gtk_misc_set_alignment(GTK_MISC(tmp), 0.0f, 0.5f);
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2258 gtk_object_set_data(GTK_OBJECT(frame), "id", (gpointer)id);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2259 gtk_object_set_data(GTK_OBJECT(frame), "label", (gpointer)tmp);
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2260 DW_MUTEX_UNLOCK;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2261 return frame;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2262 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2263
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2264 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2265 * Create a new Multiline Editbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2266 * 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
2267 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2268 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2269 HWND dw_mle_new(unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2270 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2271 GtkWidget *tmp, *tmpbox, *scroller;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2272 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2273
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2274 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
2275 #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
2276 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
2277 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
2278 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
2279 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
2280 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
2281 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
2282 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(tmp), GTK_WRAP_NONE);
122
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
2283 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
2284 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2285 tmpbox = gtk_hbox_new(FALSE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2286 tmp = gtk_text_new(NULL, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2287 gtk_text_set_word_wrap(GTK_TEXT(tmp), FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2288 gtk_text_set_line_wrap(GTK_TEXT(tmp), FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2289 scroller = gtk_vscrollbar_new(GTK_TEXT(tmp)->vadj);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2290 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
2291 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
2292 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
2293 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
2294 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2295 gtk_object_set_data(GTK_OBJECT(tmp), "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
2296 gtk_object_set_user_data(GTK_OBJECT(tmpbox), (gpointer)tmp);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2297 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2298 gtk_widget_show(tmpbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2299 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2300 return tmpbox;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2301 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2302
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2303 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2304 * Create a new Entryfield window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2305 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2306 * 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
2307 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2308 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2309 HWND dw_entryfield_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2310 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2311 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2312 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2313
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2314 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2315 tmp = gtk_entry_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2316
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2317 gtk_entry_set_text(GTK_ENTRY(tmp), text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2318
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2319 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2320 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2321
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2322 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2323 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2324 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2325
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2326 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2327 * Create a new Entryfield (password) window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2328 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2329 * 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
2330 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2331 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2332 HWND dw_entryfield_password_new(char *text, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2333 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2334 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2335 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2336
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2337 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2338 tmp = gtk_entry_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2339
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2340 gtk_entry_set_visibility(GTK_ENTRY(tmp), FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2341 gtk_entry_set_text(GTK_ENTRY(tmp), text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2342
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2343 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2344 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2345
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2346 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2347 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2348 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2349
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2350 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2351 * Create a new Combobox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2352 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2353 * 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
2354 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2355 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2356 HWND dw_combobox_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2357 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2358 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
2359 SignalHandler *work = malloc(sizeof(SignalHandler));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2360 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2361
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2362 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2363 tmp = gtk_combo_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2364 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(tmp)->entry), text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2365 gtk_combo_set_use_arrows(GTK_COMBO(tmp), TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2366 gtk_object_set_user_data(GTK_OBJECT(tmp), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2367 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2368 gtk_object_set_data(GTK_OBJECT(tmp), "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
2369
2d121d4d90c0 Run the _item_select_event() handler on comboboxes even if a handler
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 114
diff changeset
2370 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
2371 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
2372 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
2373
2d121d4d90c0 Run the _item_select_event() handler on comboboxes even if a handler
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 114
diff changeset
2374 gtk_signal_connect(GTK_OBJECT(GTK_COMBO(tmp)->list), "select_child", GTK_SIGNAL_FUNC(_item_select_event), work);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2375 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2376 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2377 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2378
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2379 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2380 * Create a new button window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2381 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2382 * 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
2383 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2384 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2385 HWND dw_button_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2386 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2387 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2388 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2389
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2390 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2391 tmp = gtk_button_new_with_label(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2392 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2393 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2394 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2395 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2396 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2397
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2398 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2399 * Create a new bitmap button window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2400 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2401 * text: Bubble help text to be displayed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2402 * id: An ID of a bitmap in the resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2403 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2404 HWND dw_bitmapbutton_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2405 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2406 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2407 GtkWidget *bitmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2408 GtkTooltips *tooltips;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2409 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2410
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2411 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2412 tmp = gtk_button_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2413 bitmap = dw_bitmap_new(id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2414
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2415 if(bitmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2416 {
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2417 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
2418 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
2419 }
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2420 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
2421 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
2422 {
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2423 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
2424 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
2425 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
2426 }
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2427 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2428 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
2429 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
2430 }
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2431
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2432 /*
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2433 * 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
2434 * Parameters:
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2435 * 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
2436 * 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
2437 * 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
2438 * 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
2439 * (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
2440 */
279
984db8aefd7f Build fixes for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
2441 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
2442 {
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2443 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
2444 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
2445 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
2446 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
2447
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2448 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
2449 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
2450 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
2451
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2452 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
2453 {
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2454 dw_window_set_bitmap(bitmap, 0, filename);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2455 gtk_container_add (GTK_CONTAINER(tmp), bitmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2456 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2457 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2458 if(text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2459 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2460 tooltips = gtk_tooltips_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2461 gtk_tooltips_set_tip(tooltips, tmp, text, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2462 gtk_object_set_data(GTK_OBJECT(tmp), "tooltip", (gpointer)tooltips);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2463 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2464 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2465 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2466 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2467 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2468
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2469 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2470 * Create a new spinbutton window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2471 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2472 * 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
2473 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2474 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2475 HWND dw_spinbutton_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2476 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2477 GtkAdjustment *adj;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2478 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2479 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2480
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2481 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2482 adj = (GtkAdjustment *)gtk_adjustment_new (1.0, 0.0, 100.0, 1.0, 5.0, 0.0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2483 tmp = gtk_spin_button_new (adj, 0, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2484 gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(tmp), TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2485 gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(tmp), TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2486 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2487 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2488 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2489 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2490 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2491
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2492 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2493 * Create a new radiobutton window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2494 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2495 * 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
2496 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2497 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2498 HWND dw_radiobutton_new(char *text, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2499 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2500 /* This will have to be fixed in the future. */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2501 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2502 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2503
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2504 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2505 tmp = gtk_radio_button_new_with_label(NULL, text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2506 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2507 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2508
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2509 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2510 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2511 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2512
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2513 /*
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2514 * 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
2515 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2516 * 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
2517 * 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
2518 * 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
2519 */
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2520 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
2521 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2522 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
2523 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
2524 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
2525
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2526 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
2527 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
2528 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
2529 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
2530 else
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2531 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
2532 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
2533 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
2534 gtk_scale_set_digits(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
2535 gtk_object_set_data(GTK_OBJECT(tmp), "adjustment", (gpointer)adjustment);
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2536 gtk_object_set_data(GTK_OBJECT(adjustment), "slider", (gpointer)tmp);
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2537 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2538 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
2539 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
2540 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2541
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2542 /*
195
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2543 * 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
2544 * Parameters:
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2545 * 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
2546 * 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
2547 * 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
2548 */
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2549 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
2550 {
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2551 GtkWidget *tmp;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2552 GtkAdjustment *adjustment;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2553 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
2554
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2555 DW_MUTEX_LOCK;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2556 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
2557 if(vertical)
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2558 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
2559 else
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2560 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
2561 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
2562 gtk_widget_show(tmp);
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2563 gtk_object_set_data(GTK_OBJECT(tmp), "adjustment", (gpointer)adjustment);
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2564 gtk_object_set_data(GTK_OBJECT(adjustment), "scrollbar", (gpointer)tmp);
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2565 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2566 DW_MUTEX_UNLOCK;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2567 return tmp;
196
3dc60d60007f Fixed a missing bracket.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 195
diff changeset
2568 }
195
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2569
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2570 /*
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 30
diff changeset
2571 * Create a new percent bar window (widget) to be packed.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2572 * 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
2573 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2574 */
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 30
diff changeset
2575 HWND dw_percent_new(unsigned long id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2576 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2577 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2578 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2579
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2580 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2581 tmp = gtk_progress_bar_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2582 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2583 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2584 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2585 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2586 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2587
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2588 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2589 * Create a new checkbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2590 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2591 * 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
2592 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2593 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2594 HWND dw_checkbox_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2595 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2596 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2597 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2598
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2599 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2600 tmp = gtk_check_button_new_with_label(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2601 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2602 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2603 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2604 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2605 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2606
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2607 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2608 * Create a new listbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2609 * 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
2610 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2611 * multi: Multiple select TRUE or FALSE.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2612 */
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2613 HWND dw_listbox_new(unsigned long id, int multi)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2614 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2615 GtkWidget *tmp, *list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2616 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2617
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2618 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2619 tmp = gtk_scrolled_window_new(NULL, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2620 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (tmp),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2621 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2622
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2623 list = gtk_list_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2624 gtk_list_set_selection_mode(GTK_LIST(list), multi ? GTK_SELECTION_MULTIPLE : GTK_SELECTION_SINGLE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2625
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2626 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(tmp),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2627 list);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2628 gtk_object_set_user_data(GTK_OBJECT(tmp), list);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2629 gtk_widget_show(list);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2630 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2631 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2632
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2633 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2634 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2635 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2636
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2637 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2638 * Sets the icon used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2639 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2640 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2641 * id: An ID to be used to specify the icon.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2642 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2643 void dw_window_set_icon(HWND handle, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2644 {
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2645 GdkBitmap *bitmap = NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2646 GdkPixmap *icon_pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2647 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2648
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2649 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
2650 icon_pixmap = _find_pixmap(&bitmap, id, handle, NULL, NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2651
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2652 if(handle->window && icon_pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2653 gdk_window_set_icon(handle->window, NULL, icon_pixmap, bitmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2654
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2655 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2656 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2657
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2658 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2659 * Sets the bitmap used for a given static window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2660 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2661 * 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
2662 * 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
2663 * (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
2664 * 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
2665 * 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
2666 * 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
2667 */
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2668 void dw_window_set_bitmap(HWND handle, unsigned long id, char *filename)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2669 {
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2670 GdkBitmap *bitmap = NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2671 GdkPixmap *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2672 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2673
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2674 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
2675 return;
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2676
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2677 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
2678 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
2679 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
2680 else
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2681 {
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2682 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
2683 #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
2684 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
2685 #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
2686 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
2687 #endif
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2688
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2689 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
2690 {
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2691 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
2692 return;
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2693 }
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2694
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2695 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
2696
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2697 /* 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
2698 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
2699 {
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2700 /* 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
2701 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
2702 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
2703 {
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2704 DW_MUTEX_UNLOCK;
279
984db8aefd7f Build fixes for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
2705 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
2706 }
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2707 }
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2708 #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
2709 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
2710
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2711 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
2712 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
2713 #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
2714 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
2715
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2716 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
2717 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
2718 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
2719 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
2720 #else
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2721 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
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
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2725 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
2726 #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
2727 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
2728 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2729 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
2730 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2731 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2732 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2733
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2734 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2735 * Sets the text used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2736 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2737 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2738 * text: The text associsated with a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2739 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2740 void dw_window_set_text(HWND handle, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2741 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2742 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2743
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2744 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2745 if(GTK_IS_ENTRY(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2746 gtk_entry_set_text(GTK_ENTRY(handle), text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2747 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2748 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(handle)->entry), text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2749 else if(GTK_IS_LABEL(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2750 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
2751 else if(GTK_IS_FRAME(handle))
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2752 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2753 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "label");
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2754 if(tmp && GTK_IS_LABEL(tmp))
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2755 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
2756 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2757 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2758 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2759
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2760 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2761 * Gets the text used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2762 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2763 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2764 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2765 * text: The text associsated with a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2766 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2767 char *dw_window_get_text(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2768 {
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2769 #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
2770 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
2771 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2772 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
2773 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2774 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2775
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2776 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2777 if(GTK_IS_ENTRY(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2778 possible = gtk_entry_get_text(GTK_ENTRY(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2779 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2780 possible = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(handle)->entry));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2781
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2782 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2783 return strdup(possible);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2784 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2785
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2786 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2787 * Disables given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2788 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2789 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2790 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2791 void dw_window_disable(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2792 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2793 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2794
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2795 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2796 gtk_widget_set_sensitive(handle, FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2797 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2798 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2799
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2800 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2801 * Enables given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2802 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2803 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2804 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2805 void dw_window_enable(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2806 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2807 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2808
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2809 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2810 gtk_widget_set_sensitive(handle, TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2811 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2812 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2813
249
5a594058687f Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 246
diff changeset
2814 /*
5a594058687f Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 246
diff changeset
2815 * 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
2816 * Parameters:
5a594058687f Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 246
diff changeset
2817 * 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
2818 * 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
2819 */
5a594058687f Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 246
diff changeset
2820 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
2821 {
267
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
2822 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
2823 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
2824
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
2825 DW_MUTEX_LOCK;
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
2826 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
2827 {
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
2828 #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
2829 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
2830 #else
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
2831 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
2832 #endif
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
2833 }
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
2834 while(list)
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
2835 {
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
2836 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
2837 {
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
2838 if(id == (int)gtk_object_get_data(GTK_OBJECT(list->data), "id"))
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
2839 {
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
2840 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
2841 g_list_free(orig);
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
2842 DW_MUTEX_UNLOCK;
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
2843 return ret;
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
2844 }
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
2845 }
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
2846 list = list->next;
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
2847 }
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
2848 if(orig)
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
2849 g_list_free(orig);
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
2850 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
2851 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
2852 }
5a594058687f Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 246
diff changeset
2853
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2854 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
2855 {
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2856 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
2857
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2858 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
2859 {
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2860 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
2861 {
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2862 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
2863 x++;
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2864 }
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2865 }
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2866 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
2867 }
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2868
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2869 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2870 * Adds text to an MLE box and returns the current point.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2871 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2872 * handle: Handle to the MLE to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2873 * buffer: Text buffer to be imported.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2874 * startpoint: Point to start entering text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2875 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2876 unsigned int dw_mle_import(HWND handle, char *buffer, int startpoint)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2877 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2878 unsigned int tmppoint = startpoint;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2879 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2880
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2881 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
2882 #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
2883 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
2884 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2885 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
2886 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2887 {
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
2888 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2889
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2890 #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
2891 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
2892 {
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2893 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
2894 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
2895 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
2896
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2897 _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
2898
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2899 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
2900 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
2901 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
2902 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
2903 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
2904 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
2905 }
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2906 #else
122
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
2907 GdkFont *font = (GdkFont *)gtk_object_get_data(GTK_OBJECT(handle), "gdkfont");
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
2908
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2909 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2910 {
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2911 GdkColor *fore = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle), "foregdk");
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2912 GdkColor *back = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle), "backgdk");
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2913 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
2914
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2915 _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
2916
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2917 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
2918 gtk_text_insert(GTK_TEXT(tmp), font, fore, back, impbuf, -1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2919 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
2920 free(impbuf);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2921 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2922 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2923 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2924 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2925 return tmppoint;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2926 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2927
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2928 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2929 * Grabs text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2930 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2931 * handle: Handle to the MLE to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2932 * buffer: Text buffer to be exported.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2933 * startpoint: Point to start grabbing text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2934 * length: Amount of text to be grabbed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2935 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2936 void dw_mle_export(HWND handle, char *buffer, int startpoint, int length)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2937 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2938 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2939 gchar *text;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2940
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2941 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
2942 #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
2943 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
2944 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2945 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
2946 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2947 {
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
2948 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2949
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
2950 #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
2951 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
2952 {
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
2953 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
2954 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
2955
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
2956 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
2957 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
2958 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
2959 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
2960 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
2961 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
2962 }
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
2963 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2964 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2965 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2966 text = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), startpoint, startpoint + length);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2967 if(text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2968 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2969 strcpy(buffer, text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2970 g_free(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2971 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2972 }
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
2973 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2974 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2975 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2976 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2977
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2978 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2979 * Obtains information about an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2980 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2981 * handle: Handle to the MLE to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2982 * bytes: A pointer to a variable to return the total bytes.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2983 * lines: A pointer to a variable to return the number of lines.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2984 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2985 void dw_mle_query(HWND handle, unsigned long *bytes, unsigned long *lines)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2986 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2987 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2988
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2989 if(bytes)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2990 *bytes = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2991 if(lines)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2992 *lines = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2993
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2994 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
2995 #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
2996 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
2997 {
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
2998 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
2999
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3000 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
3001 {
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3002 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
3003
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3004 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
3005 *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
3006 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
3007 *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
3008 }
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3009 }
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3010 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3011 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3012 {
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
3013 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3014
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3015 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3016 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3017 if(bytes)
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3018 *bytes = gtk_text_get_length(GTK_TEXT(tmp)) + 1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3019 if(lines)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3020 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3021 gchar *text;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3022
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3023 *lines = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3024 text = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), 0, bytes ? *bytes : gtk_text_get_length(GTK_TEXT(tmp)));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3025
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3026 if(text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3027 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3028 int z, len = strlen(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3029
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3030 for(z=0;z<len;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3031 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3032 if(text[z] == '\n')
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3033 (*lines)++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3034 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3035 g_free(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3036 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3037 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3038 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3039 }
120
7d2108cbcd3e Porting DW 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 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3041 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3042 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3043
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3044 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3045 * Deletes text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3046 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3047 * handle: Handle to the MLE to be deleted from.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3048 * startpoint: Point to start deleting text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3049 * length: Amount of text to be deleted.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3050 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3051 void dw_mle_delete(HWND handle, int startpoint, int length)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3052 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3053 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3054
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3055 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
3056 #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
3057 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
3058 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3059 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
3060 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3061 {
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
3062 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3063
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
3064 #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
3065 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
3066 {
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3067 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
3068 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
3069
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3070 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
3071 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
3072 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
3073 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
3074 }
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3075 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3076 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3077 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3078 gtk_text_set_point(GTK_TEXT(tmp), startpoint);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3079 gtk_text_forward_delete(GTK_TEXT(tmp), length);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3080 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3081 #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
3082 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3083 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3084 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3085
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3086 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3087 * Clears all text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3088 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3089 * handle: Handle to the MLE to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3090 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3091 void dw_mle_clear(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3092 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3093 int length, _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3094
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3095 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
3096 #if GTK_MAJOR_VERSION > 1
122
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
3097 if(GTK_IS_SCROLLED_WINDOW(handle))
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
3098 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
3099 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
122
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
3100
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
3101 if(tmp && GTK_IS_TEXT_VIEW(tmp))
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
3102 {
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
3103 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
3104
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
3105 length = -1;
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
3106 gtk_text_buffer_set_text(buffer, "", length);
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
3107 }
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
3108 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3109 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3110 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3111 {
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
3112 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3113
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3114 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3115 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3116 length = gtk_text_get_length(GTK_TEXT(tmp));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3117 gtk_text_set_point(GTK_TEXT(tmp), 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3118 gtk_text_forward_delete(GTK_TEXT(tmp), length);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3119 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3120 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3121 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3122 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3123 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3124
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3125 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3126 * Sets the visible line of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3127 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3128 * handle: Handle to the MLE.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3129 * line: Line to be visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3130 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3131 void dw_mle_set_visible(HWND handle, int line)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3132 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3133 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3134
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3135 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
3136 #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
3137 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3138 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3139 {
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
3140 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3141
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3142 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3143 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3144 unsigned long lines;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3145 float pos, ratio;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3146
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3147 dw_mle_query(handle, NULL, &lines);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3148
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3149 if(lines)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3150 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3151 ratio = (float)line/(float)lines;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3152
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3153 pos = (ratio * (float)(GTK_TEXT(tmp)->vadj->upper - GTK_TEXT(tmp)->vadj->lower)) + GTK_TEXT(tmp)->vadj->lower;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3154
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3155 gtk_adjustment_set_value(GTK_TEXT(tmp)->vadj, pos);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3156 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3157 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3158 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3159 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3160 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3161 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3162
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3163 /*
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3164 * Sets the editablity of an MLE box.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3165 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3166 * handle: Handle to the MLE.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3167 * 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
3168 */
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3169 void dw_mle_set_editable(HWND handle, int state)
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3170 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3171 int _locked_by_me = FALSE;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3172
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3173 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
3174 #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
3175 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
3176 {
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
3177 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
3178
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3179 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
3180 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
3181 }
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3182 #else
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3183 if(GTK_IS_BOX(handle))
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3184 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
3185 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3186
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3187 if(tmp && GTK_IS_TEXT(tmp))
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3188 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
3189 }
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3190 #endif
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3191 DW_MUTEX_UNLOCK;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3192 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3193
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3194 /*
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3195 * Sets the word wrap state of an MLE box.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3196 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3197 * handle: Handle to the MLE.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3198 * 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
3199 */
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3200 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
3201 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3202 int _locked_by_me = FALSE;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3203
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3204 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
3205 #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
3206 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
3207 {
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
3208 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
3209
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3210 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
3211 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
3212 }
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3213 #else
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3214 if(GTK_IS_BOX(handle))
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3215 {
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
3216 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
3217
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3218 if(tmp && GTK_IS_TEXT(tmp))
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3219 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3220 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
3221 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
3222 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3223 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3224 #endif
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3225 DW_MUTEX_UNLOCK;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3226 }
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 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3229 * Sets the current cursor position of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3230 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3231 * handle: Handle to the MLE to be positioned.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3232 * point: Point to position cursor.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3233 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3234 void dw_mle_set(HWND handle, int point)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3235 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3236 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3237
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3238 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
3239 #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
3240 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
3241 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3242 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
3243 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3244 {
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
3245 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3246
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
3247 #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
3248 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
3249 {
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3250 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
3251 GtkTextIter iter;
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3252
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3253 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
3254 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
3255 gtk_text_buffer_place_cursor(tbuffer, &iter);
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3256 }
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3257 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3258 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3259 {
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3260 unsigned long chars;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3261 float pos, ratio;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3262
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3263 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
3264
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3265 if(chars)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3266 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3267 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
3268
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3269 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
3270
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3271 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
3272 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3273 gtk_text_set_point(GTK_TEXT(tmp), point);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3274 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3275 #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
3276 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3277 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3278 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3279
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3280 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3281 * Finds text in an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3282 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3283 * handle: Handle to the MLE to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3284 * text: Text to search for.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3285 * point: Start point of search.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3286 * flags: Search specific flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3287 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3288 int dw_mle_search(HWND handle, char *text, int point, unsigned long flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3289 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3290 int _locked_by_me = FALSE, retval = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3291
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3292 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
3293 #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
3294 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
3295 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3296 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
3297 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3298 {
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
3299 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3300
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
3301 #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
3302 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
3303 {
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3304 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
3305 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
3306
54014258099a 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 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
3308 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
3309 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
3310 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
3311 }
54014258099a 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 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3313 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3314 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3315 int len = gtk_text_get_length(GTK_TEXT(tmp));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3316 gchar *tmpbuf;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3317
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3318 tmpbuf = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), 0, len);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3319 if(tmpbuf)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3320 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3321 int z, textlen;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3322
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3323 textlen = strlen(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3324
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3325 if(flags & DW_MLE_CASESENSITIVE)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3326 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3327 for(z=point;z<(len-textlen) && !retval;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3328 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3329 if(strncmp(&tmpbuf[z], text, textlen) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3330 retval = z + textlen;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3331 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3332 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3333 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3334 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3335 for(z=point;z<(len-textlen) && !retval;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3336 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3337 if(strncasecmp(&tmpbuf[z], text, textlen) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3338 retval = z + textlen;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3339 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3340 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3341
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3342 if(retval)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3343 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3344 gtk_text_set_point(GTK_TEXT(tmp), retval - textlen);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3345 gtk_editable_select_region(&(GTK_TEXT(tmp)->editable), retval - textlen, retval);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3346 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3347
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3348 g_free(tmpbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3349 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3350 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3351 #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
3352 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3353 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3354 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3355 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3356
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3357 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3358 * Stops redrawing of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3359 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3360 * handle: Handle to the MLE to freeze.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3361 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3362 void dw_mle_freeze(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3363 {
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
3364 #if GTK_MAJOR_VERSION < 2
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3365 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3366
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3367 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3368 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3369 {
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
3370 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3371
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3372 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3373 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3374 gtk_text_freeze(GTK_TEXT(tmp));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3375 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3376 }
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
3377 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
3378 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3379 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3380
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3381 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3382 * Resumes redrawing of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3383 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3384 * handle: Handle to the MLE to thaw.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3385 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3386 void dw_mle_thaw(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3387 {
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
3388 #if GTK_MAJOR_VERSION < 2
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3389 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3390
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3391 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3392 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3393 {
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
3394 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3395
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3396 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3397 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3398 gtk_text_thaw(GTK_TEXT(tmp));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3399 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3400 }
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
3401 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
3402 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3403 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3404
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3405 /*
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 30
diff changeset
3406 * Returns the range of the percent bar.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3407 * 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
3408 * handle: Handle to the percent bar to be queried.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3409 */
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 30
diff changeset
3410 unsigned int dw_percent_query_range(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3411 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3412 return 100;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3413 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3414
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3415 /*
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 30
diff changeset
3416 * Sets the percent bar position.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3417 * 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
3418 * 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
3419 * position: Position of the percent bar withing the range.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3420 */
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 30
diff changeset
3421 void dw_percent_set_pos(HWND handle, unsigned int position)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3422 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3423 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3424
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3425 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3426 gtk_progress_bar_update(GTK_PROGRESS_BAR(handle), (gfloat)position/100);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3427 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3428 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3429
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3430 /*
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3431 * 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
3432 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3433 * 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
3434 */
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3435 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
3436 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3437 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
3438 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
3439
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3440 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
3441 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
3442
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3443 DW_MUTEX_LOCK;
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3444 adjustment = (GtkAdjustment *)gtk_object_get_data(GTK_OBJECT(handle), "adjustment");
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3445 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
3446 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3447 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
3448 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
3449
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3450 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
3451 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
3452 else
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3453 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
3454 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3455 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
3456 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
3457 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3458
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3459 /*
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3460 * 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
3461 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3462 * 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
3463 * 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
3464 */
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3465 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
3466 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3467 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
3468 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
3469
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3470 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
3471 return;
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3472
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3473 DW_MUTEX_LOCK;
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3474 adjustment = (GtkAdjustment *)gtk_object_get_data(GTK_OBJECT(handle), "adjustment");
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3475 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
3476 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3477 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
3478
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3479 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
3480 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
3481 else
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3482 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
3483 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3484 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
3485 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3486
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3487 /*
195
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3488 * 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
3489 * Parameters:
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3490 * 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
3491 */
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3492 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
3493 {
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3494 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
3495 GtkAdjustment *adjustment;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3496
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3497 if(!handle)
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3498 return 0;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3499
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3500 DW_MUTEX_LOCK;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3501 adjustment = (GtkAdjustment *)gtk_object_get_data(GTK_OBJECT(handle), "adjustment");
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3502 if(adjustment)
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3503 {
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3504 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
3505 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
3506
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3507 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
3508 val = max - thisval;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3509 else
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3510 val = thisval;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3511 }
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3512 DW_MUTEX_UNLOCK;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3513 return val;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3514 }
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3515
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3516 /*
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3517 * 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
3518 * Parameters:
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3519 * 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
3520 * 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
3521 */
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3522 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
3523 {
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3524 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
3525 GtkAdjustment *adjustment;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3526
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3527 if(!handle)
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3528 return;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3529
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3530 DW_MUTEX_LOCK;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3531 adjustment = (GtkAdjustment *)gtk_object_get_data(GTK_OBJECT(handle), "adjustment");
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3532 if(adjustment)
215
03e68274623d Two scrollbar fixes for GTK... one from Mark Hessling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 214
diff changeset
3533 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
3534 DW_MUTEX_UNLOCK;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3535 }
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3536
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3537 /*
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
3538 * 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
3539 * 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
3540 * 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
3541 * 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
3542 * 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
3543 */
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
3544 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
3545 {
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
3546 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
3547 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
3548
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
3549 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
3550 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
3551
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
3552 DW_MUTEX_LOCK;
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
3553 adjustment = (GtkAdjustment *)gtk_object_get_data(GTK_OBJECT(handle), "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
3554 if(adjustment)
205
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
3555 {
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
3556 adjustment->upper = (gdouble)range;
216
bd06f8d123f0 Oops typo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 215
diff changeset
3557 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
3558 }
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
3559 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
3560 }
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
3561
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
3562 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3563 * Sets the spinbutton value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3564 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3565 * handle: Handle to the spinbutton to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3566 * position: Current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3567 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3568 void dw_spinbutton_set_pos(HWND handle, long position)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3569 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3570 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3571
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3572 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3573 gtk_spin_button_set_value(GTK_SPIN_BUTTON(handle), (gfloat)position);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3574 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3575 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3576
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3577 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3578 * Sets the spinbutton limits.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3579 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3580 * handle: Handle to the spinbutton to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3581 * position: Current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3582 * position: Current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3583 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3584 void dw_spinbutton_set_limits(HWND handle, long upper, long lower)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3585 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3586 long curval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3587 GtkAdjustment *adj;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3588 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3589
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3590 curval = dw_spinbutton_query(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3591 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3592 adj = (GtkAdjustment *)gtk_adjustment_new((gfloat)curval, (gfloat)lower, (gfloat)upper, 1.0, 5.0, 0.0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3593 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3594 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3595
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3596 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3597 * Sets the entryfield character limit.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3598 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3599 * handle: Handle to the spinbutton to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3600 * limit: Number of characters the entryfield will take.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3601 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3602 void dw_entryfield_set_limit(HWND handle, ULONG limit)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3603 {
270
d2a80e648d33 Implemented dw_entryfield_set_limit() on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 269
diff changeset
3604 int _locked_by_me = FALSE;
d2a80e648d33 Implemented dw_entryfield_set_limit() on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 269
diff changeset
3605
d2a80e648d33 Implemented dw_entryfield_set_limit() on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 269
diff changeset
3606 DW_MUTEX_LOCK;
271
38d8908c4438 Corrected incorrect typecast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 270
diff changeset
3607 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
3608 DW_MUTEX_UNLOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3609 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3610
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3611 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3612 * Returns the current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3613 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3614 * handle: Handle to the spinbutton to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3615 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3616 long dw_spinbutton_query(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3617 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3618 long retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3619 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3620
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3621 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3622 retval = (long)gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3623 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3624
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3625 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3626 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3627
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3628 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3629 * Returns the state of the checkbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3630 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3631 * handle: Handle to the checkbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3632 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3633 int dw_checkbox_query(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3634 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3635 int retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3636 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3637
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3638 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3639 retval = GTK_TOGGLE_BUTTON(handle)->active;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3640 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3641
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3642 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3643 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3644
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3645 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3646 * Sets the state of the checkbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3647 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3648 * handle: Handle to the checkbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3649 * value: TRUE for checked, FALSE for unchecked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3650 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3651 void dw_checkbox_set(HWND handle, int value)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3652 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3653 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3654
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3655 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3656 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(handle), value);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3657 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3658 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3659
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3660 /*
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3661 * 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
3662 * Parameters:
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3663 * 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
3664 * 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
3665 * title: The text title of the entry.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3666 * icon: Handle to coresponding icon.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3667 * parent: Parent handle or 0 if root.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3668 * itemdata: Item specific data.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3669 */
329
9b1953ed0bff Oops missed one parameter change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 328
diff changeset
3670 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
3671 {
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3672 #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
3673 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
3674 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
3675 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
3676 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
3677 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
3678 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
3679
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3680 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
3681 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
3682
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3683 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
3684 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
3685 && 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
3686 (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
3687 {
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
3688 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
3689
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3690 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
3691
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
3692 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
3693 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
3694 if(pixbuf)
63d68387d924 Don't unref a non-existant pixmap. (GTK 2.x)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 255
diff changeset
3695 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
3696 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
3697 }
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3698 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
3699
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3700 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
3701 #else
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3702 GtkWidget *newitem, *tree, *subtree, *label, *hbox, *pixmap;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3703 GdkPixmap *gdkpix;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3704 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
3705 int position = -1;
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3706 int _locked_by_me = FALSE;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3707
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3708 if(!handle)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3709 return NULL;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3710
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3711 DW_MUTEX_LOCK;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3712 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
3713 if(!tree || !GTK_IS_TREE(tree))
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3714 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3715 DW_MUTEX_UNLOCK;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3716 return NULL;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3717 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3718
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3719 if(item && GTK_IS_TREE_ITEM(item))
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3720 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
3721
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3722 position++;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3723
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3724 newitem = gtk_tree_item_new();
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3725 label = gtk_label_new(title);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3726 gtk_object_set_data(GTK_OBJECT(newitem), "text", (gpointer)strdup(title));
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3727 gtk_object_set_data(GTK_OBJECT(newitem), "itemdata", (gpointer)itemdata);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3728 gtk_object_set_data(GTK_OBJECT(newitem), "tree", (gpointer)tree);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3729 hbox = gtk_hbox_new(FALSE, 2);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3730 gtk_object_set_data(GTK_OBJECT(newitem), "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
3731 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
3732 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
3733 if(gdkpix)
a167001c56df Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 249
diff changeset
3734 {
a167001c56df Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 249
diff changeset
3735 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
3736 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
3737 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
3738 }
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3739 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
3740 gtk_widget_show(label);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3741 gtk_widget_show(hbox);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3742
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3743 if(parent)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3744 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3745 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
3746 if(!subtree)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3747 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3748 void *thisfunc = (void *)gtk_object_get_data(GTK_OBJECT(tree), "select-child-func");
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3749 void *work = (void *)gtk_object_get_data(GTK_OBJECT(tree), "select-child-data");
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3750
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3751 subtree = gtk_tree_new();
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3752
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3753 if(thisfunc && work)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3754 gtk_signal_connect(GTK_OBJECT(subtree), "select-child", GTK_SIGNAL_FUNC(thisfunc), work);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3755
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3756 thisfunc = (void *)gtk_object_get_data(GTK_OBJECT(tree), "container-context-func");
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3757 work = (void *)gtk_object_get_data(GTK_OBJECT(tree), "container-context-data");
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3758
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3759 if(thisfunc && work)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3760 gtk_signal_connect(GTK_OBJECT(subtree), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), work);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3761
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3762 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
3763 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
3764 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
3765 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
3766 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
3767 gtk_widget_show(subtree);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3768 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
3769 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
3770 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3771 gtk_object_set_data(GTK_OBJECT(newitem), "parenttree", (gpointer)subtree);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3772 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
3773 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3774 else
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3775 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3776 gtk_object_set_data(GTK_OBJECT(newitem), "parenttree", (gpointer)tree);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3777 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
3778 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3779 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
3780 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
3781 gtk_widget_show(newitem);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3782 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
3783 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
3784 #endif
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3785 }
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 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3788 * 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
3789 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3790 * 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
3791 * 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
3792 * 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
3793 * 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
3794 * 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
3795 */
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
3796 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
3797 {
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3798 #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
3799 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
3800 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
3801 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
3802 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
3803 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
3804 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
3805
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3806 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
3807 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
3808
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3809 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
3810 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
3811 && 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
3812 (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
3813 {
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
3814 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
3815
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3816 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
3817
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
3818 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
3819 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
3820 if(pixbuf)
63d68387d924 Don't unref a non-existant pixmap. (GTK 2.x)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 255
diff changeset
3821 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
3822 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
3823 }
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3824 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
3825
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3826 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
3827 #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
3828 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
3829 GdkPixmap *gdkpix;
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3830 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
3831 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
3832
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3833 if(!handle)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3834 return NULL;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3835
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3836 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
3837 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
3838 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
3839 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3840 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
3841 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
3842 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3843 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
3844 label = gtk_label_new(title);
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3845 gtk_object_set_data(GTK_OBJECT(item), "text", (gpointer)strdup(title));
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
3846 gtk_object_set_data(GTK_OBJECT(item), "itemdata", (gpointer)itemdata);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3847 gtk_object_set_data(GTK_OBJECT(item), "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
3848 hbox = gtk_hbox_new(FALSE, 2);
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
3849 gtk_object_set_data(GTK_OBJECT(item), "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
3850 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
3851 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
3852 if(gdkpix)
a167001c56df Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 249
diff changeset
3853 {
a167001c56df Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 249
diff changeset
3854 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
3855 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
3856 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
3857 }
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3858 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
3859 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
3860 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
3861
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3862 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
3863 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3864 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
3865 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
3866 {
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3867 void *thisfunc = (void *)gtk_object_get_data(GTK_OBJECT(tree), "select-child-func");
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3868 void *work = (void *)gtk_object_get_data(GTK_OBJECT(tree), "select-child-data");
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3869
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3870 subtree = gtk_tree_new();
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3871
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3872 if(thisfunc && work)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3873 gtk_signal_connect(GTK_OBJECT(subtree), "select-child", GTK_SIGNAL_FUNC(thisfunc), work);
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3874
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
3875 thisfunc = (void *)gtk_object_get_data(GTK_OBJECT(tree), "container-context-func");
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3876 work = (void *)gtk_object_get_data(GTK_OBJECT(tree), "container-context-data");
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3877
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3878 if(thisfunc && work)
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3879 gtk_signal_connect(GTK_OBJECT(subtree), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), work);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3880
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3881 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
3882 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
3883 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
3884 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
3885 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
3886 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
3887 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
3888 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
3889 }
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3890 gtk_object_set_data(GTK_OBJECT(item), "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
3891 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
3892 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3893 else
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3894 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3895 gtk_object_set_data(GTK_OBJECT(item), "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
3896 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
3897 }
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
3898 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
3899 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
3900 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
3901 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
3902 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
3903 #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
3904 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3905
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3906 /*
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
3907 * 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
3908 * 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
3909 * 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
3910 * 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
3911 * 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
3912 * 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
3913 */
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
3914 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
3915 {
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3916 #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
3917 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
3918 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
3919 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
3920 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
3921
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3922 if(!handle)
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3923 return;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3924
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3925 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
3926 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
3927 && 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
3928 (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
3929 {
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3930 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
3931
139
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3932 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
3933 if(pixbuf)
63d68387d924 Don't unref a non-existant pixmap. (GTK 2.x)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 255
diff changeset
3934 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
3935 }
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3936 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
3937 #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
3938 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
3939 GdkPixmap *gdkpix;
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3940 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
3941 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
3942 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
3943
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3944 if(!handle || !item)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3945 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3946
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
3947 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
3948 oldtext = (char *)gtk_object_get_data(GTK_OBJECT(item), "text");
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3949 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
3950 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
3951 label = gtk_label_new(title);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3952 gtk_object_set_data(GTK_OBJECT(item), "text", (gpointer)strdup(title));
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3953 hbox = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(item), "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
3954 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
3955 hbox = gtk_hbox_new(FALSE, 2);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3956 gtk_object_set_data(GTK_OBJECT(item), "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
3957 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
3958 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
3959 if(gdkpix)
a167001c56df Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 249
diff changeset
3960 {
a167001c56df Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 249
diff changeset
3961 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
3962 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
3963 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
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 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
3966 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
3967 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
3968 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
3969 #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
3970 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3971
c4e1139d9872 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 /*
c4e1139d9872 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 * 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
3974 * 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
3975 * 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
3976 * 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
3977 * 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
3978 */
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
3979 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
3980 {
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3981 #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
3982 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
3983 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
3984 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
3985
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3986 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
3987 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
3988
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3989 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
3990 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
3991 && 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
3992 (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
3993 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
3994 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
3995 #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
3996 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
3997
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3998 if(!handle || !item)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3999 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4000
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
4001 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
4002 gtk_object_set_data(GTK_OBJECT(item), "itemdata", (gpointer)itemdata);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4003 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
4004 #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
4005 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4006
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4007 /*
317
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4008 * 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
4009 * Parameters:
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4010 * 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
4011 * 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
4012 */
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
4013 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
4014 {
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4015 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
4016 #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
4017 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
4018 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
4019 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
4020
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4021 if(!handle || !item)
319
aed5d742896d Fixed errant returns on failure.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 317
diff changeset
4022 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
4023
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4024 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
4025 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
4026 && 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
4027 (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
4028 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
4029 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
4030 #else
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4031 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
4032
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4033 if(!handle || !item)
319
aed5d742896d Fixed errant returns on failure.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 317
diff changeset
4034 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
4035
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4036 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
4037 ret = (void *)gtk_object_get_data(GTK_OBJECT(item), "itemdata");
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4038 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
4039 #endif
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4040 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
4041 }
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4042
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4043 /*
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
4044 * 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
4045 * 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
4046 * 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
4047 * 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
4048 */
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
4049 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
4050 {
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4051 #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
4052 GtkWidget *tree;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4053 GtkTreeStore *store;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4054 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
4055
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
4056 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
4057 return;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4058
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4059 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
4060 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
4061 && 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
4062 (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
4063 {
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4064 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
4065 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
4066
139
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4067 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
4068 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
4069 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
4070 }
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4071 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
4072 #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
4073 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
4074 int _locked_by_me = FALSE;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4075
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4076 if(!handle || !item)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4077 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4078
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4079 DW_MUTEX_LOCK;
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
4080 tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
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
4081 lastselect = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(tree), "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
4082 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
4083 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
4084 gtk_tree_item_select(GTK_TREE_ITEM(item));
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
4085 gtk_object_set_data(GTK_OBJECT(tree), "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
4086 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
4087 #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
4088 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4089
143
1d57c27e4adc Moved _dw_recursive_free into GTK 2.0 #ifdefs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 142
diff changeset
4090 #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
4091 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
4092 {
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
4093 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
4094 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
4095
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
4096 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
4097 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
4098 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
4099 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
4100
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
4101 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
4102 {
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
4103 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
4104 _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
4105 } 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
4106 }
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
4107 }
143
1d57c27e4adc Moved _dw_recursive_free into GTK 2.0 #ifdefs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 142
diff changeset
4108 #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
4109
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
4110 /*
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4111 * Removes all nodes from a tree.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4112 * Parameters:
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4113 * 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
4114 */
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4115 void dw_tree_clear(HWND handle)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4116 {
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4117 #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
4118 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
4119 GtkTreeStore *store;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4120 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
4121
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4122 if(!handle)
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4123 return;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4124
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4125 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
4126 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
4127 && 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
4128 (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
4129 {
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
4130 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
4131
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
4132 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
4133 {
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
4134 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
4135 _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
4136 } 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
4137 }
139
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4138 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
4139 }
139
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4140 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
4141 #else
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4142 GtkWidget *tree;
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4143 int _locked_by_me = FALSE;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4144
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4145 if(!handle)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4146 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4147
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4148 DW_MUTEX_LOCK;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4149 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
4150 if(!tree || !GTK_IS_TREE(tree))
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4151 {
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4152 DW_MUTEX_UNLOCK;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4153 return;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4154 }
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
4155 gtk_object_set_data(GTK_OBJECT(tree), "lastselect", NULL);
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4156 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
4157 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
4158 #endif
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4159 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4160
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4161 /*
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
4162 * 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
4163 * 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
4164 * 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
4165 * 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
4166 */
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
4167 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
4168 {
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4169 #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
4170 GtkWidget *tree;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4171 GtkTreeStore *store;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4172 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
4173
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4174 if(!handle)
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4175 return;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4176
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4177 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
4178 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
4179 && 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
4180 (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
4181 {
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4182 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
4183 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
4184 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
4185 }
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4186 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
4187 #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
4188 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
4189
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4190 if(!handle || !item)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4191 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4192
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
4193 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
4194 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
4195 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
4196 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
4197 #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
4198 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4199
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4200 /*
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4201 * 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
4202 * 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
4203 * 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
4204 * 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
4205 */
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
4206 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
4207 {
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4208 #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
4209 GtkWidget *tree;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4210 GtkTreeStore *store;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4211 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
4212
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4213 if(!handle)
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4214 return;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4215
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4216 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
4217 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
4218 && 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
4219 (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
4220 {
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4221 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
4222 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
4223 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
4224 }
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;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4226 #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
4227 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
4228
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4229 if(!handle || !item)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4230 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4231
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
4232 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
4233 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
4234 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
4235 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
4236 #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
4237 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4238
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4239 /*
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4240 * Removes a node from a tree.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4241 * Parameters:
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4242 * 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
4243 * item: Handle to node to be deleted.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4244 */
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
4245 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
4246 {
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4247 #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
4248 GtkWidget *tree;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4249 GtkTreeStore *store;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4250 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
4251
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4252 if(!handle)
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4253 return;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4254
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4255 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
4256 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
4257 && 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
4258 (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
4259 {
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4260 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
4261 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
4262 }
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4263 DW_MUTEX_UNLOCK;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4264 #else
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4265 GtkWidget *tree, *lastselect, *parenttree;
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4266 int _locked_by_me = FALSE;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4267
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4268 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
4269 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4270
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4271 DW_MUTEX_LOCK;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4272 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
4273 if(!tree || !GTK_IS_TREE(tree))
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4274 {
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4275 DW_MUTEX_UNLOCK;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4276 return;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
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
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
4279 lastselect = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(tree), "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
4280
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
4281 parenttree = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(item), "parenttree");
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4282
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 if(lastselect == item)
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4284 {
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
4285 gtk_tree_item_deselect(GTK_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
4286 gtk_object_set_data(GTK_OBJECT(tree), "lastselect", NULL);
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
4287 }
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4288
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4289 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
4290 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
4291 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
4292 #endif
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4293 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4294
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4295 static int _dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator, int extra)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4296 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4297 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4298 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
4299 int z, multi;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4300 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4301
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4302 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4303 clist = gtk_clist_new_with_titles(count, (gchar **)titles);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4304 if(!clist)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4305 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4306 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4307 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4308 }
350
2216e65ad2ae Removed slider flags and container selection flags from the header file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 346
diff changeset
4309 multi = (int)gtk_object_get_data(GTK_OBJECT(handle), "multi");
2216e65ad2ae Removed slider flags and container selection flags from the header file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 346
diff changeset
4310 gtk_object_set_data(GTK_OBJECT(handle), "multi", (gpointer)multi);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4311
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4312 gtk_signal_connect(GTK_OBJECT(clist), "select_row", GTK_SIGNAL_FUNC(_select_row), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4313 gtk_signal_connect(GTK_OBJECT(clist), "unselect_row", GTK_SIGNAL_FUNC(_unselect_row), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4314
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4315 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
4316 if(multi)
2216e65ad2ae Removed slider flags and container selection flags from the header file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 346
diff changeset
4317 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
4318 else
2216e65ad2ae Removed slider flags and container selection flags from the header file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 346
diff changeset
4319 gtk_clist_set_selection_mode(GTK_CLIST(clist), GTK_SELECTION_SINGLE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4320 gtk_container_add(GTK_CONTAINER(handle), clist);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4321 gtk_object_set_user_data(GTK_OBJECT(handle), (gpointer)clist);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4322 gtk_widget_show(clist);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4323 gtk_object_set_data(GTK_OBJECT(clist), "colcount", (gpointer)count);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4324
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4325 if(extra)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4326 gtk_clist_set_column_width(GTK_CLIST(clist), 1, 120);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4327
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4328 for(z=0;z<count;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4329 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4330 if(!extra || z > 1)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4331 gtk_clist_set_column_width(GTK_CLIST(clist), z, 50);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4332 sprintf(numbuf, "%d", z);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4333 gtk_object_set_data(GTK_OBJECT(clist), numbuf, (gpointer)flags[z]);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4334 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4335
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4336 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4337 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4338 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4339
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4340 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4341 * Sets up the container columns.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4342 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4343 * handle: Handle to the container to be configured.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4344 * flags: An array of unsigned longs with column flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4345 * titles: An array of strings with column text titles.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4346 * count: The number of columns (this should match the arrays).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4347 * separator: The column number that contains the main separator.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4348 * (this item may only be used in OS/2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4349 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4350 int dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4351 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4352 return _dw_container_setup(handle, flags, titles, count, separator, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4353 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4354
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4355 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4356 * Sets up the filesystem columns, note: filesystem always has an icon/filename field.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4357 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4358 * handle: Handle to the container to be configured.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4359 * flags: An array of unsigned longs with column flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4360 * titles: An array of strings with column text titles.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4361 * count: The number of columns (this should match the arrays).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4362 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4363 int dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4364 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4365 char **newtitles = malloc(sizeof(char *) * (count + 2));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4366 unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 2));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4367
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4368 newtitles[0] = "Icon";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4369 newtitles[1] = "Filename";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4370
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4371 newflags[0] = DW_CFA_BITMAPORICON | DW_CFA_CENTER | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4372 newflags[1] = DW_CFA_STRING | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4373
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4374 memcpy(&newtitles[2], titles, sizeof(char *) * count);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4375 memcpy(&newflags[2], flags, sizeof(unsigned long) * count);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4376
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4377 _dw_container_setup(handle, newflags, newtitles, count + 2, 2, 1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4378
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4379 free(newtitles);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4380 free(newflags);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4381 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4382 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4383
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4384 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4385 * Obtains an icon from a module (or header in GTK).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4386 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4387 * module: Handle to module (DLL) in OS/2 and Windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4388 * id: A unsigned long id int the resources on OS/2 and
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4389 * Windows, on GTK this is converted to a pointer
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4390 * to an embedded XPM.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4391 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4392 unsigned long dw_icon_load(unsigned long module, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4393 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4394 return id;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4395 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4396
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4397 /*
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
4398 * 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
4399 * 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
4400 * 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
4401 * 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
4402 * (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
4403 */
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
4404 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
4405 {
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
4406 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
4407 #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
4408 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
4409 #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
4410 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
4411 #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
4412 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
4413 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
4414
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4415 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
4416 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
4417
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
4418 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
4419
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
4420 /* 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
4421 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
4422 {
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4423 /* 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
4424 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
4425 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
4426 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
4427 }
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4428
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4429 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
4430 /* 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
4431 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
4432 {
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4433 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
4434 {
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
4435 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
4436 break;
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4437 }
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4438 }
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4439
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4440 /* 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
4441 * array.
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4442 */
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4443 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
4444 {
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4445 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
4446
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
4447 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
4448 _PixmapCount++;
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4449
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4450 _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
4451
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4452 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
4453 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
4454 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
4455 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
4456 _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
4457 _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
4458 }
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4459
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4460 #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
4461 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
4462
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
4463 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
4464 {
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
4465 _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
4466 _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
4467 _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
4468
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
4469 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
4470 }
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4471 #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
4472 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
4473
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
4474 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
4475 {
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
4476 _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
4477 _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
4478
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
4479 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
4480 _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
4481 _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
4482 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
4483 }
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4484 #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
4485 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
4486 _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
4487 #endif
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4488 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
4489 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
4490 {
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
4491 _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
4492 _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
4493 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
4494 }
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
4495 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
4496 }
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
4497
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
4498 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4499 * Frees a loaded resource in OS/2 and Windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4500 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4501 * handle: Handle to icon returned by dw_icon_load().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4502 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4503 void dw_icon_free(unsigned long handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
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 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
4506 * 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
4507 * 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
4508 */
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4509 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
4510 {
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4511 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
4512
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4513 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
4514 {
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
4515 #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
4516 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
4517 {
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
4518 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
4519 _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
4520 }
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
4521 #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
4522 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
4523 {
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4524 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
4525 _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
4526 }
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4527 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
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 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
4530 _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
4531 }
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4532 _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
4533 }
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4534 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4535 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4536
72
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
4537 /* 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
4538 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
4539 {
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
4540 GList *list = (GList *)gtk_object_get_data(GTK_OBJECT(clist), "selectlist");
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
4541
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
4542 if(list)
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
4543 g_list_free(list);
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
4544
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
4545 gtk_object_set_data(GTK_OBJECT(clist), "selectlist", NULL);
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
4546
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 72
diff changeset
4547 _dw_unselecting = 1;
72
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
4548 gtk_clist_unselect_all(GTK_CLIST(clist));
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
4549 _dw_unselecting = 0;
72
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
4550 }
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
4551
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4552 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4553 * Allocates memory used to populate a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4554 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4555 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4556 * rowcount: The number of items to be populated.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4557 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4558 void *dw_container_alloc(HWND handle, int rowcount)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4559 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4560 int z, count = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4561 GtkWidget *clist;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
4562 GdkColor *fore, *back;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4563 char **blah;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4564 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4565
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4566 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4567 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4568 if(!clist)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4569 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4570 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4571 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4572 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4573
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4574 count = (int)gtk_object_get_data(GTK_OBJECT(clist), "colcount");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4575
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4576 if(!count)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4577 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4578 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4579 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4580 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4581
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4582 blah = malloc(sizeof(char *) * count);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4583 memset(blah, 0, sizeof(char *) * count);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4584
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
4585 fore = (GdkColor *)gtk_object_get_data(GTK_OBJECT(clist), "foregdk");
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
4586 back = (GdkColor *)gtk_object_get_data(GTK_OBJECT(clist), "backgdk");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4587 gtk_clist_freeze(GTK_CLIST(clist));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4588 for(z=0;z<rowcount;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4589 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4590 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
4591 if(fore)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
4592 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
4593 if(back)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
4594 gtk_clist_set_background(GTK_CLIST(clist), z, back);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4595 }
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
4596 gtk_object_set_data(GTK_OBJECT(clist), "rowcount", (gpointer)rowcount);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4597 free(blah);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4598 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4599 return (void *)handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4600 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4601
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4602 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4603 * Sets an item in specified row and column to the given data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4604 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4605 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4606 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4607 * column: Zero based column of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4608 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4609 * data: Pointer to the data to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4610 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4611 void dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4612 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4613 char numbuf[10], textbuffer[100];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4614 int flag = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4615 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4616 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4617
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4618 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4619 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4620 if(!clist)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4621 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4622 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4623 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4624 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4625
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4626 sprintf(numbuf, "%d", column);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4627 flag = (int)gtk_object_get_data(GTK_OBJECT(clist), numbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4628
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4629 if(flag & DW_CFA_BITMAPORICON)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4630 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4631 long hicon = *((long *)data);
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4632 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
4633 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
4634
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4635 if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4636 gtk_clist_set_pixmap(GTK_CLIST(clist), row, column, pixmap, bitmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4637 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4638 else if(flag & DW_CFA_STRING)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4639 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4640 char *tmp = *((char **)data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4641 gtk_clist_set_text(GTK_CLIST(clist), row, column, tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4642 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4643 else if(flag & DW_CFA_ULONG)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4644 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4645 ULONG tmp = *((ULONG *)data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4646
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4647 sprintf(textbuffer, "%lu", tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4648
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4649 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4650 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4651 else if(flag & DW_CFA_DATE)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4652 {
165
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
4653 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
4654 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
4655
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
4656 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
4657 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
4658 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
4659
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
4660 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
4661
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4662 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4663 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4664 else if(flag & DW_CFA_TIME)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4665 {
165
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
4666 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
4667 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
4668
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
4669 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
4670 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
4671 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
4672
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
4673 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
4674
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4675 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4676 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4677 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4678 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4679
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4680 /*
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4681 * 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
4682 * Parameters:
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4683 * 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
4684 * 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
4685 * 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
4686 * 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
4687 */
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4688 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
4689 {
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4690 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
4691 }
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4692
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4693 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4694 * Sets an item in specified row and column to the given data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4695 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4696 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4697 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4698 * column: Zero based column of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4699 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4700 * data: Pointer to the data to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4701 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4702 void dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, unsigned long icon)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4703 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4704 dw_container_set_item(handle, pointer, 0, row, (void *)&icon);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4705 dw_container_set_item(handle, pointer, 1, row, (void *)&filename);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4706 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4707
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4708 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4709 * Sets an item in specified row and column to the given data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4710 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4711 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4712 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4713 * column: Zero based column of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4714 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4715 * data: Pointer to the data to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4716 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4717 void dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4718 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4719 dw_container_set_item(handle, pointer, column + 2, row, data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4720 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4721
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4722 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4723 * 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
4724 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4725 * 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
4726 * 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
4727 * 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
4728 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4729 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
4730 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4731 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
4732 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
4733
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4734 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
4735 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
4736
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4737 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
4738 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
4739 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
4740 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4741
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4742 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4743 * Sets the title of a row in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4744 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4745 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4746 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4747 * title: String title of the item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4748 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4749 void dw_container_set_row_title(void *pointer, int row, char *title)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4750 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4751 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4752 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4753
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4754 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4755 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(pointer));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4756
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4757 if(clist)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4758 gtk_clist_set_row_data(GTK_CLIST(clist), row, (gpointer)title);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4759 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4760 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4761
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4762 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4763 * Sets the title of a row in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4764 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4765 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4766 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4767 * rowcount: The number of rows to be inserted.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4768 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4769 void dw_container_insert(HWND handle, void *pointer, int rowcount)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4770 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4771 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4772 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4773
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4774 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4775 clist = gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4776
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4777 if(clist && GTK_IS_CLIST(clist))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4778 gtk_clist_thaw(GTK_CLIST(clist));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4779 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4780 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4781
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4782 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4783 * 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
4784 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4785 * 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
4786 * 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
4787 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4788 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
4789 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4790 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
4791 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
4792
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4793 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
4794 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
4795 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
4796 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4797 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
4798
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4799 rows = (int)gtk_object_get_data(GTK_OBJECT(clist), "rowcount");
72
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
4800
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
4801 _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
4802
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4803 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
4804 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
4805
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4806 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
4807 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
4808 else
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4809 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
4810
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4811 gtk_object_set_data(GTK_OBJECT(clist), "rowcount", (gpointer)rows);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4812 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4813 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
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
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4816 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4817 * Removes all rows from a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4818 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4819 * 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
4820 * redraw: TRUE to cause the container to redraw immediately.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4821 */
52
0804483f6320 Added a redraw parameter to dw_container_clear().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 51
diff changeset
4822 void dw_container_clear(HWND handle, int redraw)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4823 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4824 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4825 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4826
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4827 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4828 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4829 if(clist && GTK_IS_CLIST(clist))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4830 {
72
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
4831 _dw_unselect(clist);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4832 gtk_clist_clear(GTK_CLIST(clist));
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
4833 gtk_object_set_data(GTK_OBJECT(clist), "rowcount", (gpointer)0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4834 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4835 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4836 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4837
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4838 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4839 * 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
4840 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4841 * 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
4842 * 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
4843 * 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
4844 * 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
4845 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4846 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
4847 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4848 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
4849 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
4850 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
4851
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4852 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
4853 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
4854 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
4855 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4856 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
4857 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
4858 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4859 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
4860 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4861 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
4862 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
4863 break;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4864 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
4865 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
4866 break;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4867 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4868 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
4869 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4870 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4871 DW_MUTEX_UNLOCK;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4872 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4873
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4874 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4875 * Starts a new query of a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4876 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4877 * handle: Handle to the window (widget) to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4878 * flags: If this parameter is DW_CRA_SELECTED it will only
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4879 * return items that are currently selected. Otherwise
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4880 * it will return all records in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4881 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4882 char *dw_container_query_start(HWND handle, unsigned long flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4883 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4884 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4885 GList *list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4886 char *retval = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4887 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4888
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4889 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4890 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4891
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4892 if(!clist)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4893 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4894 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4895 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4896 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4897
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4898 /* These should be separate but right now this will work */
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4899 if(flags & DW_CRA_SELECTED || flags & DW_CRA_CURSORED)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4900 {
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4901 /* If there is an old query list, free it */
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4902 list = (GList *)gtk_object_get_data(GTK_OBJECT(clist), "querylist");
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4903 if(list)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4904 g_list_free(list);
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4905
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4906 /* Move the current selection list to the query list, and remove the
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4907 * current selection list.
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4908 */
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4909 list = (GList *)gtk_object_get_data(GTK_OBJECT(clist), "selectlist");
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4910 gtk_object_set_data(GTK_OBJECT(clist), "selectlist", NULL);
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4911 gtk_object_set_data(GTK_OBJECT(clist), "querylist", (gpointer)list);
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
4912 _dw_unselect(clist);
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4913
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4914 if(list)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4915 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4916 gtk_object_set_data(GTK_OBJECT(clist), "querypos", (gpointer)1);
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4917 if(list->data)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4918 retval = list->data;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4919 else
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4920 retval = "";
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4921 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4922 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4923 else
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4924 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4925 retval = (char *)gtk_clist_get_row_data(GTK_CLIST(clist), 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4926 gtk_object_set_data(GTK_OBJECT(clist), "querypos", (gpointer)1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4927 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4928 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4929 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4930 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4931
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4932 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4933 * Continues an existing query of a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4934 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4935 * handle: Handle to the window (widget) to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4936 * flags: If this parameter is DW_CRA_SELECTED it will only
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4937 * return items that are currently selected. Otherwise
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4938 * it will return all records in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4939 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4940 char *dw_container_query_next(HWND handle, unsigned long flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4941 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4942 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4943 GList *list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4944 char *retval = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4945 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4946
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4947 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4948 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4949
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4950 if(!clist)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4951 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4952 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4953 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4954 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4955
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4956 /* These should be separate but right now this will work */
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4957 if(flags & DW_CRA_SELECTED || flags & DW_CRA_CURSORED)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4958 {
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4959 list = (GList *)gtk_object_get_data(GTK_OBJECT(clist), "querylist");
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4960
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4961 if(list)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4962 {
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4963 int counter = 0, pos = (int)gtk_object_get_data(GTK_OBJECT(clist), "querypos");
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4964 gtk_object_set_data(GTK_OBJECT(clist), "querypos", (gpointer)pos+1);
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4965
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4966 while(list && counter < pos)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4967 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4968 list = list->next;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4969 counter++;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4970 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4971
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4972 if(list && list->data)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4973 retval = list->data;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4974 else if(list && !list->data)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4975 retval = "";
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4976 }
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4977 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4978 else
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4979 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4980 int pos = (int)gtk_object_get_data(GTK_OBJECT(clist), "querypos");
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4981
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4982 retval = (char *)gtk_clist_get_row_data(GTK_CLIST(clist), pos);
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4983 gtk_object_set_data(GTK_OBJECT(clist), "querypos", (gpointer)pos+1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4984 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4985 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4986 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4987 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4988
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4989 /*
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4990 * 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
4991 * Parameters:
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4992 * 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
4993 * 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
4994 */
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4995 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
4996 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4997 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
4998 GtkWidget *clist;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4999 int rowcount, z;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5000 char *rowdata;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5001
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5002 DW_MUTEX_LOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5003 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
5004
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5005 if(!clist)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5006 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5007 DW_MUTEX_UNLOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5008 return;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5009 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5010 rowcount = (int)gtk_object_get_data(GTK_OBJECT(clist), "rowcount");
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5011
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5012 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
5013 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5014 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
5015 if(rowdata == text)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5016 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5017 gfloat pos;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5018 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
5019
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
5020 _dw_unselect(clist);
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
5021
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5022 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
5023
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5024 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
5025 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
5026 DW_MUTEX_UNLOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5027 return;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5028 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5029 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5030
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5031 DW_MUTEX_UNLOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5032 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5033
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5034 /*
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5035 * 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
5036 * Parameters:
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5037 * 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
5038 * 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
5039 */
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5040 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
5041 {
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5042 int _locked_by_me = FALSE;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5043 GtkWidget *clist;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5044 int rowcount, z;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5045 char *rowdata;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5046
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5047 DW_MUTEX_LOCK;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5048 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
5049
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5050 if(!clist)
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5051 {
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5052 DW_MUTEX_UNLOCK;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5053 return;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5054 }
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5055 rowcount = (int)gtk_object_get_data(GTK_OBJECT(clist), "rowcount");
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5056
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5057 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
5058 {
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5059 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
5060 if(rowdata == text)
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5061 {
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5062 _dw_unselect(clist);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5063
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5064 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
5065
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5066 rowcount--;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5067
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5068 gtk_object_set_data(GTK_OBJECT(clist), "rowcount", (gpointer)rowcount);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5069 DW_MUTEX_UNLOCK;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5070 return;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5071 }
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5072 }
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5073
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5074 DW_MUTEX_UNLOCK;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5075 }
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5076
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5077 /*
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5078 * 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
5079 * Parameters:
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5080 * 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
5081 */
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5082 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
5083 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5084 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
5085 GtkWidget *clist;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5086 int colcount, z;
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 DW_MUTEX_LOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5089 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
5090
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5091 if(!clist)
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 DW_MUTEX_UNLOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5094 return;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5095 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5096 colcount = (int)gtk_object_get_data(GTK_OBJECT(clist), "colcount");
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5097 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
5098 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5099 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
5100 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
5101 }
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 }
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 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5106 * Creates a rendering context widget (window) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5107 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5108 * id: An id to be used with dw_window_from_id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5109 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5110 * A handle to the widget or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5111 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5112 HWND dw_render_new(unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5113 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5114 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5115 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5116
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5117 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5118 tmp = gtk_drawing_area_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5119 gtk_widget_set_events(tmp, GDK_EXPOSURE_MASK
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5120 | GDK_LEAVE_NOTIFY_MASK
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5121 | 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
5122 | GDK_KEY_PRESS_MASK
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5123 | GDK_POINTER_MOTION_MASK
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5124 | GDK_POINTER_MOTION_HINT_MASK);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5125 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
267
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
5126 GTK_WIDGET_SET_FLAGS(tmp, GTK_CAN_FOCUS);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5127 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5128 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5129 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5130 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5131
193
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
5132 /* 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
5133 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
5134 {
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
5135 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
5136 {
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
5137 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
5138 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
5139 }
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
5140 else if (value < 16)
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
5141 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
5142 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
5143 }
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
5144
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5145 /* Sets the current foreground drawing color.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5146 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5147 * red: red value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5148 * green: green value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5149 * blue: blue value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5150 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5151 void dw_color_foreground_set(unsigned long value)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5152 {
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5153 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
5154 GdkColor color = _internal_color(value);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5155
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5156 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5157 gdk_color_alloc(_dw_cmap, &color);
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5158 _foreground[index] = color;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5159 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5160 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5161
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5162 /* Sets the current background drawing color.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5163 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5164 * red: red value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5165 * green: green value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5166 * blue: blue value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5167 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5168 void dw_color_background_set(unsigned long value)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5169 {
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5170 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
5171 GdkColor color = _internal_color(value);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5172
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5173 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5174 gdk_color_alloc(_dw_cmap, &color);
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5175 _background[index] = color;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5176 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5177 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5178
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5179 GdkGC *_set_colors(GdkWindow *window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5180 {
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5181 GdkGC *gc = NULL;
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5182 int index = _find_thread_index(dw_thread_id());
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5183
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5184 if(!window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5185 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5186 gc = gdk_gc_new(window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5187 if(gc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5188 {
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5189 gdk_gc_set_foreground(gc, &_foreground[index]);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5190 gdk_gc_set_background(gc, &_background[index]);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5191 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5192 return gc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5193 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5194
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5195 /* Draw a point on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5196 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5197 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5198 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5199 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5200 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5201 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5202 void dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5203 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5204 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5205 GdkGC *gc = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5206
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5207 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5208 if(handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5209 gc = _set_colors(handle->window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5210 else if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5211 gc = _set_colors(pixmap->pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5212 if(gc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5213 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5214 gdk_draw_point(handle ? handle->window : pixmap->pixmap, gc, x, y);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5215 gdk_gc_unref(gc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5216 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5217 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5218 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5219
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5220 /* Draw a line on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5221 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5222 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5223 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5224 * x1: First X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5225 * y1: First Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5226 * x2: Second X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5227 * y2: Second Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5228 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5229 void dw_draw_line(HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5230 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5231 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5232 GdkGC *gc = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5233
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5234 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5235 if(handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5236 gc = _set_colors(handle->window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5237 else if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5238 gc = _set_colors(pixmap->pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5239 if(gc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5240 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5241 gdk_draw_line(handle ? handle->window : pixmap->pixmap, gc, x1, y1, x2, y2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5242 gdk_gc_unref(gc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5243 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5244 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5245 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5246
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5247 /* Draw a rectangle on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5248 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5249 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5250 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5251 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5252 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5253 * width: Width of rectangle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5254 * height: Height of rectangle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5255 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5256 void dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5257 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5258 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5259 GdkGC *gc = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5260
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5261 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5262 if(handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5263 gc = _set_colors(handle->window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5264 else if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5265 gc = _set_colors(pixmap->pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5266 if(gc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5267 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5268 gdk_draw_rectangle(handle ? handle->window : pixmap->pixmap, gc, fill, x, y, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5269 gdk_gc_unref(gc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5270 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5271 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5272 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5273
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5274 /* Draw text on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5275 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5276 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5277 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5278 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5279 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5280 * text: Text to be displayed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5281 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5282 void dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5283 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5284 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5285 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
5286 #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
5287 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
5288 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5289 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
5290 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5291 char *fontname = "fixed";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5292
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
5293 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
5294 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
5295
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5296 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5297 if(handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5298 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5299 fontname = (char *)gtk_object_get_data(GTK_OBJECT(handle), "fontname");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5300 gc = _set_colors(handle->window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5301 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5302 else if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5303 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5304 fontname = (char *)gtk_object_get_data(GTK_OBJECT(pixmap->handle), "fontname");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5305 gc = _set_colors(pixmap->pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5306 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5307 if(gc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5308 {
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
5309 #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
5310 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
5311 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
5312 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5313 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
5314
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5315 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
5316 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5317 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
5318
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5319 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
5320 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5321 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
5322 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
5323
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5324 gdk_draw_layout(handle ? handle->window : pixmap->pixmap, gc, x, y + 2, 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
5325
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5326 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
5327 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5328 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
5329 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5330 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
5331 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5332 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5333 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
5334 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
5335 font = gdk_font_load("fixed");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5336 if(font)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5337 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5338 gint ascent;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5339
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5340 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
5341 gdk_draw_text(handle ? handle->window : pixmap->pixmap, font, gc, x, y + ascent + 2, text, strlen(text));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5342 gdk_font_unref(font);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5343 }
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
5344 #endif
149
6028f787f7c8 Fixed a graphics context leak in dw_draw_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 148
diff changeset
5345 gdk_gc_unref(gc);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5346 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5347 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5348 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5349
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
5350 /* 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
5351 * 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
5352 * 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
5353 * 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
5354 * 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
5355 * 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
5356 * 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
5357 */
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
5358 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
5359 {
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
5360 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
5361 #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
5362 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
5363 #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
5364 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
5365 #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
5366 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
5367
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
5368 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
5369 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
5370
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
5371 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
5372 if(handle)
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
5373 fontname = (char *)gtk_object_get_data(GTK_OBJECT(handle), "fontname");
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
5374 else if(pixmap)
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 fontname = (char *)gtk_object_get_data(GTK_OBJECT(pixmap->handle), "fontname");
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
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
5377 #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
5378 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
5379 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
5380 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5381 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
5382
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5383 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
5384 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5385 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
5386
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5387 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
5388 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5389 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
5390
b479002e013f Upped the 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 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
5392 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
5393 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
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 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
5396 *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
5397 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
5398 *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
5399
b479002e013f Upped the 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 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
5401 }
b479002e013f Upped the 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 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
5403 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5404 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
5405 }
b479002e013f Upped the 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 #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
5407
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
5408 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
5409 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
5410 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
5411 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
5412 {
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
5413 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
5414 *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
5415 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
5416 *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
5417 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
5418 }
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
5419 #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
5420 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
5421 }
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5422
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5423 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5424 * Creates a pixmap with given parameters.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5425 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5426 * handle: Window handle the pixmap is associated with.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5427 * width: Width of the pixmap in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5428 * height: Height of the pixmap in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5429 * depth: Color depth of the pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5430 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5431 * A handle to a pixmap or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5432 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5433 HPIXMAP dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5434 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5435 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5436 HPIXMAP pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5437
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5438 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5439 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5440
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5441 if (!depth)
66
664a274a46a6 Fixed color depth problem when creating a new pixmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 63
diff changeset
5442 depth = -1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5443
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5444 pixmap->width = width; pixmap->height = height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5445
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5446
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5447 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5448 pixmap->handle = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5449 pixmap->pixmap = gdk_pixmap_new(handle->window, width, height, depth);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5450 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5451 return pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5452 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5453
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5454 /*
241
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5455 * Creates a pixmap from a file.
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5456 * Parameters:
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5457 * 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
5458 * 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
5459 * DW pick the appropriate file extension.
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5460 * (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
5461 * Returns:
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5462 * 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
5463 */
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5464 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
5465 {
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5466 int _locked_by_me = FALSE;
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5467 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
5468 #ifndef USE_IMLIB
241
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5469 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
5470 #endif
241
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5471 #if GTK_MAJOR_VERSION > 1
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5472 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
5473 #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
5474 GdkImlibImage *image;
241
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5475 #endif
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5476 char *file = alloca(strlen(filename) + 5);
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5477
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5478 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
5479 return NULL;
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5480
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5481 strcpy(file, filename);
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5482
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5483 /* 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
5484 if(access(file, 04) != 0)
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5485 {
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5486 /* Try with .xpm extention */
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5487 strcat(file, ".xpm");
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5488 if(access(file, 04) != 0)
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5489 {
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5490 free(pixmap);
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5491 return NULL;
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5492 }
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5493 }
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5494
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5495 DW_MUTEX_LOCK;
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5496 #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
5497 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
5498
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5499 pixmap->width = gdk_pixbuf_get_width(pixbuf);
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5500 pixmap->height = gdk_pixbuf_get_height(pixbuf);
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5501
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5502 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
5503 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
5504 #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
5505 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
5506
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
5507 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
5508 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
5509
245
11baf43efbc2 Must call gdk_imlib_render() before gdk_imlib_copy_image().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 244
diff changeset
5510 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
5511 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
5512 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
5513 #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
5514 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
5515 #endif
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5516 pixmap->handle = handle;
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5517 DW_MUTEX_UNLOCK;
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5518 return pixmap;
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5519 }
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5520
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5521 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5522 * Creates a pixmap from internal resource graphic specified by id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5523 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5524 * handle: Window handle the pixmap is associated with.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5525 * id: Resource ID associated with requested pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5526 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5527 * A handle to a pixmap or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5528 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5529 HPIXMAP dw_pixmap_grab(HWND handle, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5530 {
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5531 GdkBitmap *bitmap = NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5532 HPIXMAP pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5533 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5534
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5535 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5536 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5537
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5538
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5539 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
5540 pixmap->pixmap = _find_pixmap(&bitmap, id, handle, &pixmap->width, &pixmap->height);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5541 if(pixmap->pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5542 {
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
5543 #if GTK_MAJOR_VERSION < 2
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5544 GdkPixmapPrivate *pvt = (GdkPixmapPrivate *)pixmap->pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5545 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
5546 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5547 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5548 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5549 return pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5550 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5551
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5552 /* Call this after drawing to the screen to make sure
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5553 * anything you have drawn is visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5554 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5555 void dw_flush(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5556 {
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
5557 #if GTK_MAJOR_VERSION < 2
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5558 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5559
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5560 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5561 gdk_flush();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5562 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
5563 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5564 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5565
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5566 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5567 * Destroys an allocated pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5568 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5569 * pixmap: Handle to a pixmap returned by
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5570 * dw_pixmap_new..
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5571 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5572 void dw_pixmap_destroy(HPIXMAP pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5573 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5574 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5575
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5576 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5577 gdk_pixmap_unref(pixmap->pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5578 free(pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5579 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5580 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5581
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5582 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5583 * Copies from one item to another.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5584 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5585 * dest: Destination window handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5586 * destp: Destination pixmap. (choose only one).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5587 * xdest: X coordinate of destination.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5588 * ydest: Y coordinate of destination.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5589 * width: Width of area to copy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5590 * height: Height of area to copy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5591 * src: Source window handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5592 * srcp: Source pixmap. (choose only one).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5593 * xsrc: X coordinate of source.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5594 * ysrc: Y coordinate of source.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5595 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5596 void dw_pixmap_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5597 {
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
5598 /* 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
5599 * 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
5600 * 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
5601 * 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
5602 */
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5603 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5604 GdkGC *gc = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5605
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
5606 if((!dest && (!destp || !destp->pixmap)) || (!src && (!srcp || !srcp->pixmap)))
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5607 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5608
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5609 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5610 if(dest)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5611 gc = _set_colors(dest->window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5612 else if(src)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5613 gc = _set_colors(src->window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5614 else if(destp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5615 gc = gdk_gc_new(destp->pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5616 else if(srcp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5617 gc = gdk_gc_new(srcp->pixmap);
122
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
5618
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
5619 if(gc)
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
5620 {
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
5621 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
5622 gdk_gc_unref(gc);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5623 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5624 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5625 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5626
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5627 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5628 * Emits a beep.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5629 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5630 * freq: Frequency.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5631 * dur: Duration.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5632 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5633 void dw_beep(int freq, int dur)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5634 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5635 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5636
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5637 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5638 gdk_beep();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5639 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5640 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5641
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5642 void _my_strlwr(char *buf)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5643 {
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5644 int z, len = strlen(buf);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5645
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5646 for(z=0;z<len;z++)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5647 {
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5648 if(buf[z] >= 'A' && buf[z] <= 'Z')
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5649 buf[z] -= 'A' - 'a';
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5650 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5651 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5652
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5653 /* Open a shared library and return a handle.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5654 * Parameters:
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5655 * name: Base name of the shared library.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5656 * handle: Pointer to a module handle,
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5657 * will be filled in with the handle.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5658 */
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5659 int dw_module_load(char *name, HMOD *handle)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5660 {
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5661 int len;
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5662 char *newname;
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5663 char errorbuf[1024];
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5664
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5665
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5666 if(!handle)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5667 return -1;
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5668
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5669 if((len = strlen(name)) == 0)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5670 return -1;
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5671
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5672 /* Lenth + "lib" + ".so" + NULL */
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5673 newname = malloc(len + 7);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5674
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5675 if(!newname)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5676 return -1;
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5677
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5678 sprintf(newname, "lib%s.so", name);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5679 _my_strlwr(newname);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5680
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5681 *handle = dlopen(newname, RTLD_NOW);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5682 if(*handle == NULL)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5683 {
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5684 strncpy(errorbuf, dlerror(), 1024);
164
d35771f70bdd Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 163
diff changeset
5685 printf("%s\n", errorbuf);
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5686 sprintf(newname, "lib%s.so", name);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5687 *handle = dlopen(newname, RTLD_NOW);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5688 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5689
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5690 free(newname);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5691
163
0322836c5299 Return -1 on error from dw_module_load().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 162
diff changeset
5692 return (NULL == *handle) ? -1 : 0;
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5693 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5694
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5695 /* Queries the address of a symbol within open handle.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5696 * Parameters:
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5697 * handle: Module handle returned by dw_module_load()
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5698 * name: Name of the symbol you want the address of.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5699 * func: A pointer to a function pointer, to obtain
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5700 * the address.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5701 */
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5702 int dw_module_symbol(HMOD handle, char *name, void**func)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5703 {
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5704 if(!func || !name)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5705 return -1;
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5706
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5707 if(strlen(name) == 0)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5708 return -1;
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5709
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5710 *func = (void*)dlsym(handle, name);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5711 return (NULL == *func);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5712 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5713
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5714 /* Frees the shared library previously opened.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5715 * Parameters:
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5716 * handle: Module handle returned by dw_module_load()
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5717 */
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5718 int dw_module_close(HMOD handle)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5719 {
162
df59a3fc6de6 Fixed a minor bug in dw_module_close().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
5720 if(handle)
df59a3fc6de6 Fixed a minor bug in dw_module_close().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
5721 return dlclose(handle);
df59a3fc6de6 Fixed a minor bug in dw_module_close().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
5722 return 0;
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5723 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5724
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5725 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5726 * Returns the handle to an unnamed mutex semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5727 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5728 HMTX dw_mutex_new(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5729 {
239
403b07f873e1 Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 237
diff changeset
5730 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
5731
403b07f873e1 Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 237
diff changeset
5732 pthread_mutex_init(mutex, NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5733 return mutex;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5734 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5735
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5736 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5737 * Closes a semaphore created by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5738 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5739 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5740 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5741 void dw_mutex_close(HMTX mutex)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5742 {
239
403b07f873e1 Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 237
diff changeset
5743 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
5744 {
403b07f873e1 Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 237
diff changeset
5745 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
5746 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
5747 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5748 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5749
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5750 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5751 * Tries to gain access to the semaphore, if it can't it blocks.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5752 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5753 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5754 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5755 void dw_mutex_lock(HMTX mutex)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5756 {
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
5757 /* 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
5758 * 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
5759 */
baaf4b04d284 Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 94
diff changeset
5760 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
5761 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
5762
239
403b07f873e1 Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 237
diff changeset
5763 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
5764
baaf4b04d284 Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 94
diff changeset
5765 /* 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
5766 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
5767 gdk_threads_enter();
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5768 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5769
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5770 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5771 * Reliquishes the access to the semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5772 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5773 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5774 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5775 void dw_mutex_unlock(HMTX mutex)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5776 {
239
403b07f873e1 Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 237
diff changeset
5777 pthread_mutex_unlock(mutex);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5778 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5779
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5780 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5781 * Returns the handle to an unnamed event semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5782 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5783 HEV dw_event_new(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5784 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5785 HEV eve = (HEV)malloc(sizeof(struct _dw_unix_event));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5786
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5787 if(!eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5788 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5789
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5790 /* We need to be careful here, mutexes on Linux are
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5791 * FAST by default but are error checking on other
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5792 * systems such as FreeBSD and OS/2, perhaps others.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5793 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5794 pthread_mutex_init (&(eve->mutex), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5795 pthread_mutex_lock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5796 pthread_cond_init (&(eve->event), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5797
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5798 pthread_mutex_unlock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5799 eve->alive = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5800 eve->posted = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5801
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5802 return eve;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5803 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5804
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5805 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5806 * Resets a semaphore created by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5807 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5808 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5809 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5810 int dw_event_reset (HEV eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5811 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5812 if(!eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5813 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5814
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5815 pthread_mutex_lock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5816 pthread_cond_broadcast (&(eve->event));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5817 pthread_cond_init (&(eve->event), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5818 eve->posted = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5819 pthread_mutex_unlock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5820 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5821 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5822
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5823 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5824 * Posts a semaphore created by dw_event_new(). Causing all threads
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5825 * waiting on this event in dw_event_wait to continue.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5826 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5827 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5828 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5829 int dw_event_post (HEV eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5830 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5831 if(!eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5832 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5833
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5834 pthread_mutex_lock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5835 pthread_cond_broadcast (&(eve->event));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5836 eve->posted = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5837 pthread_mutex_unlock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5838 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5839 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5840
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5841 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5842 * Waits on a semaphore created by dw_event_new(), until the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5843 * event gets posted or until the timeout expires.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5844 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5845 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5846 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5847 int dw_event_wait(HEV eve, unsigned long timeout)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5848 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5849 int rc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5850 struct timeval now;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5851 struct timespec timeo;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5852
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5853 if(!eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5854 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5855
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5856 if(eve->posted)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5857 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5858
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5859 pthread_mutex_lock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5860 gettimeofday(&now, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5861 timeo.tv_sec = now.tv_sec + (timeout / 1000);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5862 timeo.tv_nsec = now.tv_usec * 1000;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5863 rc = pthread_cond_timedwait (&(eve->event), &(eve->mutex), &timeo);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5864 pthread_mutex_unlock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5865 if(!rc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5866 return 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5867 if(rc == ETIMEDOUT)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5868 return -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5869 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5870 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5871
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5872 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5873 * Closes a semaphore created by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5874 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5875 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5876 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5877 int dw_event_close(HEV *eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5878 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5879 if(!eve || !(*eve))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5880 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5881
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5882 pthread_mutex_lock (&((*eve)->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5883 pthread_cond_destroy (&((*eve)->event));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5884 pthread_mutex_unlock (&((*eve)->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5885 pthread_mutex_destroy (&((*eve)->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5886 free(*eve);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5887 *eve = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5888
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5889 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5890 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5891
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5892 /*
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5893 * Setup thread independent color sets.
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5894 */
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5895 void _dwthreadstart(void *data)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5896 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5897 void (*threadfunc)(void *) = NULL;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5898 void **tmp = (void **)data;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5899
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5900 threadfunc = (void (*)(void *))tmp[0];
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5901
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5902 _dw_thread_add(dw_thread_id());
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5903 threadfunc(tmp[1]);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5904 _dw_thread_remove(dw_thread_id());
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5905 free(tmp);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5906 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5907 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5908 * Creates a new thread with a starting point of func.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5909 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5910 * func: Function which will be run in the new thread.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5911 * data: Parameter(s) passed to the function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5912 * stack: Stack size of new thread (OS/2 and Windows only).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5913 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5914 DWTID dw_thread_new(void *func, void *data, int stack)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5915 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5916 DWTID gtkthread;
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5917 void **tmp = malloc(sizeof(void *) * 2);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5918
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5919 tmp[0] = func;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5920 tmp[1] = data;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5921
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5922 pthread_create(&gtkthread, NULL, (void *)_dwthreadstart, (void *)tmp);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5923 return gtkthread;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5924 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5925
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5926 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5927 * Ends execution of current thread immediately.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5928 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5929 void dw_thread_end(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5930 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5931 pthread_exit(NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5932 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5933
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5934 /*
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5935 * Returns the current thread's ID.
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5936 */
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5937 DWTID dw_thread_id(void)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5938 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5939 return (DWTID)pthread_self();
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5940 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5941
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5942 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5943 * Cleanly terminates a DW session, should be signal handler safe.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5944 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5945 * exitcode: Exit code reported to the operating system.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5946 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5947 void dw_exit(int exitcode)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5948 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5949 exit(exitcode);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5950 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5951
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5952 #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
5953
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5954 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5955 * Pack windows (widgets) into a box from the end (or bottom).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5956 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5957 * box: Window handle of the box to be packed into.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5958 * item: Window handle of the item to be back.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5959 * width: Width in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5960 * height: Height in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5961 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5962 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5963 * pad: Number of pixels of padding around the item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5964 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5965 void dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5966 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5967 int _locked_by_me = FALSE;
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5968 GtkWidget *tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5969
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5970 if(!box)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5971 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5972
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5973 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5974
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5975 if((tmp = gtk_object_get_data(GTK_OBJECT(box), "boxhandle")))
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5976 box = tmp;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5977
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5978 if(!item)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5979 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5980 item = gtk_label_new("");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5981 gtk_widget_show(item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5982 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5983
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5984 if(GTK_IS_TABLE(box))
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5985 {
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5986 int boxcount = (int)gtk_object_get_data(GTK_OBJECT(box), "boxcount");
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5987 int boxtype = (int)gtk_object_get_data(GTK_OBJECT(box), "boxtype");
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5988
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5989 /* 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
5990 * 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
5991 * 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
5992 * 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
5993 */
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5994 if(GTK_IS_TABLE(item))
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5995 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5996 GtkWidget *eventbox = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(item), "eventbox");
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5997
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5998 if(eventbox)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5999 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6000 gtk_container_add(GTK_CONTAINER(eventbox), item);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6001 pad = (int)gtk_object_get_data(GTK_OBJECT(item), "boxpad");
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6002 item = eventbox;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6003 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6004 }
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
6005
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
6006 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
6007 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
6008 else
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
6009 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
6010
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
6011 gtk_table_attach(GTK_TABLE(box), item, 0, 1, 0, 1, hsize ? DW_EXPAND : 0, vsize ? DW_EXPAND : 0, pad, pad);
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
6012 gtk_object_set_data(GTK_OBJECT(box), "boxcount", (gpointer)boxcount + 1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6013 gtk_widget_set_usize(item, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6014 if(GTK_IS_RADIO_BUTTON(item))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6015 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6016 GSList *group;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6017 GtkWidget *groupstart = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(box), "group");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6018
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6019 if(groupstart)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6020 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6021 group = gtk_radio_button_group(GTK_RADIO_BUTTON(groupstart));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6022 gtk_radio_button_set_group(GTK_RADIO_BUTTON(item), group);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6023 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6024 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6025 gtk_object_set_data(GTK_OBJECT(box), "group", (gpointer)item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6026 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6027 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6028 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6029 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6030 GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6031
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6032 if(GTK_IS_TABLE(item))
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6033 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6034 GtkWidget *eventbox = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(item), "eventbox");
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6035
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6036 if(eventbox)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6037 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6038 gtk_container_add(GTK_CONTAINER(eventbox), item);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6039 pad = (int)gtk_object_get_data(GTK_OBJECT(item), "boxpad");
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6040 item = eventbox;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6041 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6042 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6043
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6044 gtk_container_border_width(GTK_CONTAINER(box), pad);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6045 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
6046 gtk_box_pack_end(GTK_BOX(vbox), item, TRUE, TRUE, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6047 gtk_widget_show(vbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6048
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6049 gtk_widget_set_usize(item, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6050 gtk_object_set_user_data(GTK_OBJECT(box), vbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6051 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6052 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6053 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6054
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6055 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6056 * Sets the size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6057 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6058 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6059 * width: New width in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6060 * height: New height in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6061 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6062 void dw_window_set_usize(HWND handle, unsigned long width, unsigned long height)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6063 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6064 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6065
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
6066 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
6067 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
6068
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6069 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6070 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
6071 {
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6072 _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
6073 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
6074 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
6075 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
6076 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
6077 {
49ac97060328 Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 271
diff changeset
6078 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
6079 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
6080 }
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
6081 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6082 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6083 gtk_widget_set_usize(handle, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6084 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6085 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6086
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6087 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6088 * Returns the width of the screen.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6089 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6090 int dw_screen_width(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6091 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6092 int retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6093 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6094
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6095 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6096 retval = gdk_screen_width();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6097 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6098 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6099 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6100
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6101 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6102 * Returns the height of the screen.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6103 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6104 int dw_screen_height(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6105 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6106 int retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6107 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6108
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6109 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6110 retval = gdk_screen_height();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6111 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6112 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6113 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6114
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6115 /* This should return the current color depth */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6116 unsigned long dw_color_depth(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6117 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6118 int retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6119 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6120
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6121 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
6122 retval = gdk_visual_get_best_depth();
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6123 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6124 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6125 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6126
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6127 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6128 * Sets the position of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6129 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6130 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6131 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6132 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6133 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6134 void dw_window_set_pos(HWND handle, unsigned long x, unsigned long y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6135 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6136 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6137
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6138 DW_MUTEX_LOCK;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
6139 if(handle && handle->window)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6140 gdk_window_move(handle->window, x, y);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6141 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6142 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6143
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6144 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6145 * Sets the position and size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6146 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6147 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6148 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6149 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6150 * width: Width of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6151 * height: Height of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6152 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6153 void dw_window_set_pos_size(HWND handle, unsigned long x, unsigned long y, unsigned long width, unsigned long height)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6154 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6155 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6156
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
6157 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
6158 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
6159
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
6160 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
6161 if(GTK_IS_WINDOW(handle))
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6162 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6163 _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
6164
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
6165 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
6166 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
6167 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
6168 gtk_window_set_default_size(GTK_WINDOW(handle), width - _dw_border_width, height - _dw_border_height);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6169 }
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
6170 else if(handle->window)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6171 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6172 gdk_window_resize(handle->window, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6173 gdk_window_move(handle->window, x, y);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6174 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6175 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6176 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6177
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6178 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6179 * Gets the position and size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6180 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6181 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6182 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6183 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6184 * width: Width of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6185 * height: Height of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6186 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6187 void dw_window_get_pos_size(HWND handle, ULONG *x, ULONG *y, ULONG *width, ULONG *height)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6188 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6189 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6190 gint gx, gy, gwidth, gheight, gdepth;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6191
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
6192 if(handle && handle->window)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6193 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6194 DW_MUTEX_LOCK;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
6195
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6196 gdk_window_get_geometry(handle->window, &gx, &gy, &gwidth, &gheight, &gdepth);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6197 gdk_window_get_root_origin(handle->window, &gx, &gy);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6198 if(x)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6199 *x = gx;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6200 if(y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6201 *y = gy;
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6202 if(GTK_IS_WINDOW(handle))
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6203 {
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6204 if(width)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6205 *width = gwidth + _dw_border_width;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6206 if(height)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6207 *height = gheight + _dw_border_height;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6208 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6209 else
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6210 {
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6211 if(width)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6212 *width = gwidth;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6213 if(height)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6214 *height = gheight;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6215 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6216 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6217 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6218 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6219
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6220 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6221 * Sets the style of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6222 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6223 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6224 * width: New width in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6225 * height: New height in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6226 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6227 void dw_window_set_style(HWND handle, unsigned long style, unsigned long mask)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6228 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6229 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6230 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6231
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6232 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6233 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6234 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6235 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6236 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6237 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6238 }
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
6239 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
6240 {
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6241 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
6242 {
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6243 gfloat x, y;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6244
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6245 x = y = DW_LEFT;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6246
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6247 if(style & DW_DT_CENTER)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6248 x = DW_CENTER;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6249
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6250 if(style & DW_DT_VCENTER)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6251 y = DW_CENTER;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6252
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6253 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
6254 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6255 if(style & DW_DT_WORDBREAK)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6256 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
6257 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6258 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6259 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6260
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6261 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6262 * Adds a new page to specified notebook.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6263 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6264 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6265 * flags: Any additional page creation flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6266 * front: If TRUE page is added at the beginning.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6267 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6268 unsigned long dw_notebook_page_new(HWND handle, unsigned long flags, int front)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6269 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6270 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6271 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
6272 GtkWidget **pagearray;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6273
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6274 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
6275 pagearray = (GtkWidget **)gtk_object_get_data(GTK_OBJECT(handle), "pagearray");
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6276
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6277 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
6278 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6279 for(z=0;z<256;z++)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6280 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6281 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
6282 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6283 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
6284 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
6285
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6286 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
6287 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
6288
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6289 sprintf(text, "page%d", z);
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6290 /* 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
6291 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
6292 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
6293 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
6294 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6295 }
15
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
6296 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6297 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
6298
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6299 /* Hopefully this won't happen. */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6300 return 256;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6301 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6302
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6303 /* 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
6304 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
6305 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6306 int z;
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6307 GtkWidget *thispage, **pagearray = gtk_object_get_data(GTK_OBJECT(handle), "pagearray");
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6308
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6309 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
6310 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6311 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
6312 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6313 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
6314 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6315 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
6316 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
6317 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6318 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6319 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6320 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
6321 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6322
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6323 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6324 * Remove a page from a notebook.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6325 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6326 * handle: Handle to the notebook widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6327 * pageid: ID of the page to be destroyed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6328 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6329 void dw_notebook_page_destroy(HWND handle, unsigned int pageid)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6330 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6331 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
6332 GtkWidget **pagearray;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6333
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6334 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
6335 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
6336 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
6337 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6338 gtk_notebook_remove_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
6339 if((pagearray = gtk_object_get_data(GTK_OBJECT(handle), "pagearray")))
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6340 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
6341 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6342 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6343 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6344
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6345 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6346 * Queries the currently visible page ID.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6347 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6348 * handle: Handle to the notebook widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6349 */
346
81fae15885d7 Implemented switch-page on OS/2, and changed the signal prototype to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 345
diff changeset
6350 unsigned long dw_notebook_page_query(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6351 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6352 int retval, phys;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6353 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6354
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6355 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
6356 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
6357 retval = _get_logical_page(handle, phys);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6358 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6359 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6360 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6361
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6362 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6363 * Sets the currently visibale page ID.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6364 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6365 * handle: Handle to the notebook widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6366 * pageid: ID of the page to be made visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6367 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6368 void dw_notebook_page_set(HWND handle, unsigned int pageid)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6369 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6370 int realpage, _locked_by_me = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6371
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6372 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
6373 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
6374 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
6375 gtk_notebook_set_page(GTK_NOTEBOOK(handle), pageid);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6376 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6377 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6378
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6379
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6380 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6381 * Sets the text on the specified notebook tab.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6382 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6383 * handle: Notebook handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6384 * pageid: Page ID of the tab to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6385 * text: Pointer to the text to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6386 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6387 void dw_notebook_page_set_text(HWND handle, unsigned long pageid, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6388 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6389 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
6390 int realpage, _locked_by_me = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6391
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6392 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
6393 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
6394 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
6395 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6396 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
6397 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
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 sprintf(ptext, "page%d", (int)pageid);
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6400 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
6401 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
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
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6404 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
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 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
6407 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
6408 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
6409 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6410 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6411 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6412
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6413 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6414 * Sets the text on the specified notebook tab status area.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6415 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6416 * handle: Notebook handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6417 * pageid: Page ID of the tab to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6418 * text: Pointer to the text to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6419 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6420 void dw_notebook_page_set_status_text(HWND handle, unsigned long pageid, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6421 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6422 /* TODO (if possible) */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6423 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6424
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6425 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6426 * Packs the specified box into the notebook page.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6427 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6428 * handle: Handle to the notebook to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6429 * pageid: Page ID in the notebook which is being packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6430 * page: Box handle to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6431 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6432 void dw_notebook_pack(HWND handle, unsigned long pageid, HWND page)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6433 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6434 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
6435 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
6436 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
6437 char ptext[100];
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6438
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6439 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
6440 sprintf(ptext, "page%d", (int)pageid);
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6441 num = (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
6442 gtk_object_set_data(GTK_OBJECT(handle), ptext, NULL);
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6443 pagearray = (GtkWidget **)gtk_object_get_data(GTK_OBJECT(handle), "pagearray");
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6444
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6445 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
6446 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6447 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
6448 return;
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6449 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6450
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6451 /* 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
6452 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
6453 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6454 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
6455 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6456 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
6457 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
6458 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6459 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
6460 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
6461 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
6462 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
6463 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
6464 break;
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6465 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6466 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6467 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6468
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6469 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
6470
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
6471 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
6472
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6473 if(GTK_IS_TABLE(page))
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6474 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6475 pad = (int)gtk_object_get_data(GTK_OBJECT(page), "boxpad");
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6476 gtk_container_border_width(GTK_CONTAINER(page), pad);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6477 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6478
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6479 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
6480 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
6481 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
6482 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
6483 else
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6484 gtk_notebook_insert_page(GTK_NOTEBOOK(handle), page, label, 256);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6485 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6486 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6487
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6488 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6489 * Appends the specified text to the listbox's (or combobox) entry list.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6490 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6491 * handle: Handle to the listbox to be appended to.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6492 * text: Text to append into listbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6493 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6494 void dw_listbox_append(HWND handle, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6495 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6496 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6497 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6498
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6499 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6500 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6501 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6502 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6503 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6504 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6505 }
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6506 gtk_object_set_data(GTK_OBJECT(handle), "appending", (gpointer)1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6507 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6508 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6509 GtkWidget *list_item;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6510 GList *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6511 char *font = (char *)gtk_object_get_data(GTK_OBJECT(handle), "font");
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
6512 GdkColor *fore = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle2), "foregdk");
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
6513 GdkColor *back = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle2), "backgdk");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6514
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6515 list_item=gtk_list_item_new_with_label(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6516
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6517 if(font)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6518 _set_font(GTK_LIST_ITEM(list_item)->item.bin.child, font);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6519 if(fore && back)
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
6520 _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
6521 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
6522 DW_RGB(back->red, back->green, back->blue));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6523
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6524 tmp = g_list_append(NULL, list_item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6525 gtk_widget_show(list_item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6526 gtk_list_append_items(GTK_LIST(handle2),tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6527 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6528 else if(GTK_IS_COMBO(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6529 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6530 GList *tmp = (GList *)gtk_object_get_user_data(GTK_OBJECT(handle2));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6531 char *addtext = strdup(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6532
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6533 if(addtext)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6534 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6535 tmp = g_list_append(tmp, addtext);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6536 gtk_object_set_user_data(GTK_OBJECT(handle2), tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6537 gtk_combo_set_popdown_strings(GTK_COMBO(handle2), tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6538 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6539 }
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6540 gtk_object_set_data(GTK_OBJECT(handle), "appending", NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6541 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6542 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6543
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6544 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6545 * Clears the listbox's (or combobox) list of all entries.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6546 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6547 * handle: Handle to the listbox to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6548 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6549 void dw_listbox_clear(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6550 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6551 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6552 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6553
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6554 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6555 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6556 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6557 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6558 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6559 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6560 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6561 if(GTK_IS_COMBO(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6562 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6563 GList *list, *tmp = (GList *)gtk_object_get_user_data(GTK_OBJECT(handle2));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6564
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6565 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6566 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6567 list = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6568 while(list)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6569 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6570 if(list->data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6571 free(list->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6572 list=list->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6573 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6574 g_list_free(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6575 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6576 gtk_object_set_user_data(GTK_OBJECT(handle2), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6577 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6578 else if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6579 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6580 int count = dw_listbox_count(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6581
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6582 gtk_list_clear_items(GTK_LIST(handle2), 0, count - 1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6583 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6584 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6585 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6586
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6587 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6588 * Returns the listbox's item count.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6589 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6590 * handle: Handle to the listbox to be counted
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6591 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6592 int dw_listbox_count(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6593 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6594 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6595 int retval = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6596 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6597
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6598 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6599 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6600 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6601 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6602 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6603 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6604 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6605 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6606 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6607 handle2 = GTK_COMBO(handle)->list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6608 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6609 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6610 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6611 GList *list = GTK_LIST(handle2)->children;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6612 while(list)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6613 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6614 list = list->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6615 retval++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6616 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6617 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6618 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6619 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6620 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6621
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6622 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6623 * Sets the topmost item in the viewport.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6624 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6625 * handle: Handle to the listbox to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6626 * top: Index to the top item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6627 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6628 void dw_listbox_set_top(HWND handle, int top)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6629 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6630 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6631 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6632
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6633 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6634 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6635 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6636 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6637 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6638 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6639 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6640 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6641 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6642 int count = dw_listbox_count(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6643 GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6644 float pos, ratio;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6645
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6646 if(count)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6647 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6648 ratio = (float)top/(float)count;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6649
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6650 pos = (ratio * (float)(adj->upper - adj->lower)) + adj->lower;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6651
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6652 gtk_adjustment_set_value(adj, pos);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6653 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6654 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6655 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6656 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6657
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6658 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6659 * Copies the given index item's text into buffer.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6660 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6661 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6662 * index: Index into the list to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6663 * buffer: Buffer where text will be copied.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6664 * length: Length of the buffer (including NULL).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6665 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6666 void dw_listbox_query_text(HWND handle, unsigned int index, char *buffer, unsigned int length)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6667 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6668 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6669 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6670
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6671 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6672 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6673 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6674 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6675 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6676 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6677 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6678 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6679 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6680 handle2 = GTK_COMBO(handle)->list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6681 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6682 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6683 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6684 int counter = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6685 GList *list = GTK_LIST(handle2)->children;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6686
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6687 while(list)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6688 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6689 if(counter == index)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6690 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6691 gchar *text = "";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6692
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6693 if(GTK_IS_LIST_ITEM(list->data))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6694 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6695 GtkListItem *li = GTK_LIST_ITEM(list->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6696
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6697 if(GTK_IS_ITEM(&(li->item)))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6698 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6699 GtkItem *i = &(li->item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6700
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6701 if(GTK_IS_BIN(&(i->bin)))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6702 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6703 GtkBin *b = &(i->bin);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6704
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6705 if(GTK_IS_LABEL(b->child))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6706 gtk_label_get(GTK_LABEL(b->child), &text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6707 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6708 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6709 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6710 else if(GTK_IS_COMBO(handle) && list->data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6711 text = (gchar *)list->data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6712
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6713 strncpy(buffer, (char *)text, length);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6714 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6715 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6716 list = list->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6717 counter++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6718 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6719 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6720 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6721 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6722
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6723 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6724 * Sets the text of a given listbox entry.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6725 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6726 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6727 * index: Index into the list to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6728 * buffer: Buffer where text will be copied.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6729 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6730 void dw_listbox_set_text(HWND handle, unsigned int index, char *buffer)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6731 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6732 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6733 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6734
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6735 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6736 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6737 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6738 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6739 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6740 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6741 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6742 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6743 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6744 handle2 = GTK_COMBO(handle)->list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6745 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6746 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6747 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6748 int counter = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6749 GList *list = GTK_LIST(handle2)->children;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6750
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6751 while(list)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6752 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6753 if(counter == index)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6754 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6755
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6756 if(GTK_IS_LIST_ITEM(list->data))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6757 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6758 GtkListItem *li = GTK_LIST_ITEM(list->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6759
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6760 if(GTK_IS_ITEM(&(li->item)))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6761 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6762 GtkItem *i = &(li->item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6763
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6764 if(GTK_IS_BIN(&(i->bin)))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6765 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6766 GtkBin *b = &(i->bin);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6767
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6768 if(GTK_IS_LABEL(b->child))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6769 gtk_label_set_text(GTK_LABEL(b->child), buffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6770 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6771 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6772 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6773 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6774 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6775 if(list->data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6776 g_free(list->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6777 list->data = g_strdup(buffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6778 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6779 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6780 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6781 list = list->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6782 counter++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6783 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6784 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6785 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6786 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6787
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
6788 #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
6789 /* 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
6790 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
6791 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6792 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
6793 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6794 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
6795 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
6796
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6797 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
6798 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6799 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
6800 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6801 #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
6802
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6803 /*
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6804 * 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
6805 * Parameters:
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6806 * 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
6807 * 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
6808 */
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6809 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
6810 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6811 GtkWidget *handle2 = handle;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6812 int retval = DW_LIT_NONE;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6813 int _locked_by_me = FALSE;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6814
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6815 DW_MUTEX_LOCK;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6816 if(GTK_IS_SCROLLED_WINDOW(handle))
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6817 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6818 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
6819 if(tmp)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6820 handle2 = tmp;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6821 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6822 if(GTK_IS_LIST(handle2))
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6823 {
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
6824 #if GTK_MAJOR_VERSION > 1
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6825 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
6826 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
6827
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6828 while(list)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6829 {
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
6830 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
6831
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6832 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
6833 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
6834 && 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
6835 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6836 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
6837 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
6838 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6839
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6840
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6841 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
6842 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
6843 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6844 #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
6845 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
6846 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
6847
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6848 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
6849 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6850 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
6851 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6852 retval = counter;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6853 break;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6854 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6855
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6856 list = list->next;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6857 counter++;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6858 }
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
6859 #endif
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6860 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6861 DW_MUTEX_UNLOCK;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6862 return retval;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6863 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6864
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6865 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6866 * Returns the index to the item in the list currently selected.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6867 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6868 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6869 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6870 unsigned int dw_listbox_selected(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6871 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6872 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6873 int retval = DW_LIT_NONE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6874 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6875
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6876 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6877 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6878 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6879 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6880 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6881 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6882 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6883 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6884 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6885 retval = (unsigned int)gtk_object_get_data(GTK_OBJECT(handle), "item");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6886 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6887 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6888 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6889 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6890 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6891 int counter = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6892 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
6893 #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
6894 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
6895 #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
6896 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
6897 #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
6898 if(selection)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6899 {
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
6900 while(list)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6901 {
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
6902 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
6903 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6904 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
6905 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
6906 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6907
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6908 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
6909 counter++;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6910 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6911 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6912 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6913 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6914 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6915 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6916
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6917 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6918 * Sets the selection state of a given index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6919 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6920 * handle: Handle to the listbox to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6921 * index: Item index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6922 * state: TRUE if selected FALSE if unselected.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6923 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6924 void dw_listbox_select(HWND handle, int index, int state)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6925 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6926 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6927 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6928
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6929 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6930 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6931 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6932 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6933 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6934 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6935 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6936 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6937 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6938 handle2 = GTK_COMBO(handle)->list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6939 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6940 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6941 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6942 if(state)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6943 gtk_list_select_item(GTK_LIST(handle2), index);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6944 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6945 gtk_list_unselect_item(GTK_LIST(handle2), index);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6946 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6947 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6948 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6949
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6950 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6951 * Deletes the item with given index from the list.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6952 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6953 * handle: Handle to the listbox to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6954 * index: Item index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6955 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6956 void dw_listbox_delete(HWND handle, int index)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6957 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6958 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6959 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6960
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6961 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6962 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6963 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6964 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6965 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6966 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6967 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6968 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6969 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6970 handle2 = GTK_COMBO(handle)->list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6971 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6972 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6973 gtk_list_clear_items(GTK_LIST(handle2), index, index);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6974 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6975 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6976
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
6977 /* 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
6978 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
6979 {
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
6980 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
6981 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
6982 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
6983
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
6984 /* 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
6985 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
6986 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
6987
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
6988 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
6989
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
6990 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
6991 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
6992
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
6993 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
6994 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
6995 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
6996 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
6997 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
6998 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
6999 }
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7000
122
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
7001 #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
7002 /* 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
7003 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
7004 {
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
7005 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
7006 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
7007 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
7008
145
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
7009 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
7010 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
7011
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7012 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
7013 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
7014 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
7015 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
7016
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7017 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
7018 *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
7019 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7020 #endif
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7021
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7022 /*
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7023 * 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
7024 * 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
7025 * 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
7026 * 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
7027 * 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
7028 * Returns:
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7029 * 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
7030 */
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7031 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
7032 {
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7033 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
7034 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
7035 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
7036
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7037 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
7038 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
7039 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
7040 else
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7041 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
7042 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
7043 gtk_paned_add2(GTK_PANED(tmp), bottomright);
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7044 gtk_object_set_data(GTK_OBJECT(tmp), "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
7045 *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
7046 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
7047 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
7048 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
7049 #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
7050 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
7051 #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
7052 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
7053 #endif
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7054 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
7055 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
7056 return tmp;
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7057 }
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7058
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7059 /*
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7060 * 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
7061 * Parameters:
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7062 * 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
7063 */
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7064 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
7065 {
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7066 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
7067 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
7068
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
7069 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
7070 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
7071 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
7072 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
7073
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7074 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
7075 *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
7076
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
7077 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
7078 {
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
7079 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
7080
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
7081 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
7082 }
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7083 }
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7084
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7085 /*
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7086 * 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
7087 * Parameters:
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7088 * 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
7089 */
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7090 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
7091 {
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7092 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
7093
7d2108cbcd3e Porting DW 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 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
7095 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
7096 return 0.0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7097 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7098
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7099 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7100 * Pack windows (widgets) into a box from the start (or top).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7101 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7102 * box: Window handle of the box to be packed into.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7103 * item: Window handle of the item to be back.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7104 * width: Width in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7105 * height: Height in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7106 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7107 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7108 * pad: Number of pixels of padding around the item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7109 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7110 void dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7111 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7112 int _locked_by_me = FALSE;
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
7113 GtkWidget *tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7114
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7115 if(!box)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7116 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7117
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7118 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7119
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
7120 if((tmp = gtk_object_get_data(GTK_OBJECT(box), "boxhandle")))
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
7121 box = tmp;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
7122
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7123 if(!item)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7124 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7125 item = gtk_label_new("");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7126 gtk_widget_show(item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7127 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7128
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
7129 if(GTK_IS_TABLE(box))
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7130 {
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
7131 int boxcount = (int)gtk_object_get_data(GTK_OBJECT(box), "boxcount");
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
7132 int boxtype = (int)gtk_object_get_data(GTK_OBJECT(box), "boxtype");
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
7133 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
7134
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
7135 /* 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
7136 * 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
7137 * 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
7138 * 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
7139 */
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
7140 if(GTK_IS_TABLE(item))
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7141 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7142 GtkWidget *eventbox = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(item), "eventbox");
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7143
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7144 if(eventbox)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7145 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7146 gtk_container_add(GTK_CONTAINER(eventbox), item);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7147 pad = (int)gtk_object_get_data(GTK_OBJECT(item), "boxpad");
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7148 item = eventbox;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7149 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7150 }
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
7151
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
7152 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
7153 {
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
7154 x = 0;
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
7155 y = boxcount;
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
7156 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
7157 }
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
7158 else
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
7159 {
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
7160 x = boxcount;
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
7161 y = 0;
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
7162 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
7163 }
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
7164
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
7165 gtk_table_attach(GTK_TABLE(box), item, x, x + 1, y, y + 1, hsize ? DW_EXPAND : 0, vsize ? DW_EXPAND : 0, pad, pad);
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
7166 gtk_object_set_data(GTK_OBJECT(box), "boxcount", (gpointer)boxcount + 1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7167 gtk_widget_set_usize(item, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7168 if(GTK_IS_RADIO_BUTTON(item))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7169 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7170 GSList *group;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7171 GtkWidget *groupstart = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(box), "group");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7172
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7173 if(groupstart)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7174 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7175 group = gtk_radio_button_group(GTK_RADIO_BUTTON(groupstart));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7176 gtk_radio_button_set_group(GTK_RADIO_BUTTON(item), group);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7177 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7178 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7179 gtk_object_set_data(GTK_OBJECT(box), "group", (gpointer)item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7180 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7181 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7182 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7183 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7184 GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7185
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7186 if(GTK_IS_TABLE(item))
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7187 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7188 GtkWidget *eventbox = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(item), "eventbox");
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7189
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7190 if(eventbox)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7191 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7192 gtk_container_add(GTK_CONTAINER(eventbox), item);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7193 pad = (int)gtk_object_get_data(GTK_OBJECT(item), "boxpad");
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7194 item = eventbox;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7195 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7196 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7197
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7198 gtk_container_border_width(GTK_CONTAINER(box), pad);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7199 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
7200 gtk_box_pack_end(GTK_BOX(vbox), item, TRUE, TRUE, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7201 gtk_widget_show(vbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7202
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7203 gtk_widget_set_usize(item, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7204 gtk_object_set_user_data(GTK_OBJECT(box), vbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7205 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7206 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7207 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7208
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7209 /*
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
7210 * 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
7211 * 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
7212 * 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
7213 * 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
7214 */
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
7215 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
7216 {
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
7217 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
7218
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
7219 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
7220 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
7221
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
7222 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
7223 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
7224 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
7225 }
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
7226
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
7227 /*
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
7228 * 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
7229 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
7230 * 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
7231 * 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
7232 */
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
7233 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
7234 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
7235 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
7236
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
7237 if(!window)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
7238 return;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
7239
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
7240 DW_MUTEX_LOCK;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
7241 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
7242 DW_MUTEX_UNLOCK;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
7243 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
7244
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
7245 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7246 * Returns some information about the current operating environment.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7247 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7248 * env: Pointer to a DWEnv struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7249 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7250 void dw_environment_query(DWEnv *env)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7251 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7252 struct utsname name;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7253 char tempbuf[100];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7254 int len, z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7255
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7256 uname(&name);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7257 strcpy(env->osName, name.sysname);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7258 strcpy(tempbuf, name.release);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7259
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7260 env->MajorBuild = env->MinorBuild = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7261
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7262 len = strlen(tempbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7263
15
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
7264 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
7265 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
7266 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
7267 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
7268 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
7269
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7270 for(z=1;z<len;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7271 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7272 if(tempbuf[z] == '.')
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7273 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7274 tempbuf[z] = '\0';
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7275 env->MajorVersion = atoi(&tempbuf[z-1]);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7276 env->MinorVersion = atoi(&tempbuf[z+1]);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7277 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7278 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7279 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7280 env->MajorVersion = atoi(tempbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7281 env->MinorVersion = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7282 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7283
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7284 /* 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
7285 static gint _gtk_file_ok(GtkWidget *widget, DWDialog *dwwait)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7286 {
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7287 #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
7288 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
7289 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7290 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
7291 #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
7292 char *tmpdup=NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7293
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
7294 if(!dwwait)
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
7295 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
7296
214
0e98514a3905 Applied patch from Mark Hessling to prevent the return buffer from the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 208
diff changeset
7297 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
7298 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
7299 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
7300 _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
7301 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
7302 return FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7303 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7304
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7305 /* 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
7306 static gint _gtk_file_cancel(GtkWidget *widget, DWDialog *dwwait)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7307 {
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
7308 if(!dwwait)
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
7309 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
7310
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
7311 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
7312 _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
7313 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
7314 return FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7315 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7316
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7317 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7318 * Opens a file dialog and queries user selection.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7319 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7320 * title: Title bar text for dialog.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7321 * defpath: The default path of the open dialog.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7322 * ext: Default file extention.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7323 * flags: DW_FILE_OPEN or DW_FILE_SAVE.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7324 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7325 * NULL on error. A malloced buffer containing
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7326 * the file path on success.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7327 *
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7328 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7329 char *dw_file_browse(char *title, char *defpath, char *ext, int flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7330 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7331 GtkWidget *filew;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7332 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
7333 DWDialog *dwwait;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7334
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7335 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7336
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7337 /* The DW mutex should be sufficient for
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7338 * insuring no thread changes this unknowingly.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7339 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7340 if(_dw_file_active)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7341 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7342 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7343 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7344 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7345
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7346 _dw_file_active = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7347
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7348 filew = gtk_file_selection_new(title);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7349
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
7350 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
7351
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
7352 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
7353 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filew)->cancel_button), "clicked", (GtkSignalFunc) _gtk_file_cancel, dwwait);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7354
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7355 if(defpath)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7356 gtk_file_selection_set_filename(GTK_FILE_SELECTION(filew), defpath);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7357
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7358 gtk_widget_show(filew);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7359
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7360 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7361
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
7362 return (char *)dw_dialog_wait(dwwait);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7363 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7364
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7365
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7366 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7367 * Execute and external program in a seperate session.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7368 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7369 * program: Program name with optional path.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7370 * type: Either DW_EXEC_CON or DW_EXEC_GUI.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7371 * params: An array of pointers to string arguements.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7372 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7373 * -1 on error.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7374 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7375 int dw_exec(char *program, int type, char **params)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7376 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7377 int ret = -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7378
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7379 if((ret = fork()) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7380 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7381 int i;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7382
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7383 for (i = 3; i < 256; i++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7384 close(i);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7385 setsid();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7386 if(type == DW_EXEC_GUI)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7387 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7388 execvp(program, params);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7389 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7390 else if(type == DW_EXEC_CON)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7391 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7392 char **tmpargs;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7393
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7394 if(!params)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7395 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7396 tmpargs = malloc(sizeof(char *));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7397 tmpargs[0] = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7398 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7399 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7400 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7401 int z = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7402
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7403 while(params[z])
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7404 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7405 z++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7406 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7407 tmpargs = malloc(sizeof(char *)*(z+3));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7408 z=0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7409 tmpargs[0] = "xterm";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7410 tmpargs[1] = "-e";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7411 while(params[z])
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7412 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7413 tmpargs[z+2] = params[z];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7414 z++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7415 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7416 tmpargs[z+2] = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7417 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7418 execvp("xterm", tmpargs);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7419 free(tmpargs);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7420 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7421 /* If we got here exec failed */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7422 _exit(-1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7423 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7424 return ret;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7425 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7426
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7427 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7428 * Loads a web browser pointed at the given URL.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7429 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7430 * url: Uniform resource locator.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7431 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7432 int dw_browse(char *url)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7433 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7434 /* Is there a way to find the webbrowser in Unix? */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7435 char *execargs[3], *browser = "netscape";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7436
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7437 execargs[0] = browser;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7438 execargs[1] = url;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7439 execargs[2] = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7440
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7441 return dw_exec(browser, DW_EXEC_GUI, execargs);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7442 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7443
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7444 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7445 * Returns a pointer to a static buffer which containes the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7446 * current user directory. Or the root directory (C:\ on
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7447 * OS/2 and Windows).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7448 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7449 char *dw_user_dir(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7450 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7451 static char _user_dir[1024] = "";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7452
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7453 if(!_user_dir[0])
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7454 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7455 char *home = getenv("HOME");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7456
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7457 if(home)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7458 strcpy(_user_dir, home);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7459 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7460 strcpy(_user_dir, "/");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7461 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7462 return _user_dir;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7463 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7464
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7465 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7466 * Call a function from the window (widget)'s context.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7467 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7468 * handle: Window handle of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7469 * function: Function pointer to be called.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7470 * data: Pointer to the data to be passed to the function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7471 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7472 void dw_window_function(HWND handle, void *function, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7473 {
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
7474 void (* windowfunc)(void *);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
7475
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
7476 windowfunc = function;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
7477
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
7478 if(windowfunc)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
7479 windowfunc(data);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7480 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7481
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
7482 /*
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
7483 * 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
7484 * Parameters:
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
7485 * 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
7486 * 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
7487 * 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
7488 */
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
7489 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
7490 {
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
7491 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
7492
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
7493 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
7494 return;
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
7495
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
7496 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
7497 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
7498 {
cf0115e38ef0 On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
7499 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
7500 {
cf0115e38ef0 On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
7501 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
7502
cf0115e38ef0 On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
7503 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
7504 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
7505 }
cf0115e38ef0 On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
7506 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
7507 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
7508 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
7509 }
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
7510 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
7511 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
7512
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
7513 /*
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
7514 * 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
7515 * Parameters:
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
7516 * 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
7517 * 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
7518 * 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
7519 */
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
7520 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
7521 {
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
7522 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
7523 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
7524
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
7525 if(!window)
92
0a085f295e81 A couple more minor changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 91
diff changeset
7526 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
7527
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
7528 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
7529 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
7530 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
7531 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
7532 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
7533 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
7534
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7535 /*
195
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7536 * 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
7537 * Parameters:
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7538 * 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
7539 * 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
7540 * 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
7541 * Returns:
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7542 * 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
7543 */
199
b955228477b3 Removed the window parameter to dw_timer_connect() it was no needed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 198
diff changeset
7544 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
7545 {
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7546 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
7547
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7548 DW_MUTEX_LOCK;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7549 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
7550 DW_MUTEX_UNLOCK;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7551 return tag;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7552 }
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7553
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7554 /*
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7555 * Removes timer callback.
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7556 * Parameters:
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7557 * 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
7558 */
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7559 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
7560 {
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7561 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
7562
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7563 DW_MUTEX_LOCK;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7564 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
7565 DW_MUTEX_UNLOCK;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7566 }
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7567
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7568 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7569 * Add a callback to a window event.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7570 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7571 * window: Window handle of signal to be called back.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7572 * signame: A string pointer identifying which signal to be hooked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7573 * sigfunc: The pointer to the function to be used as the callback.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7574 * data: User data to be passed to the handler function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7575 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7576 void dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7577 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7578 SignalHandler *work = malloc(sizeof(SignalHandler));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7579 void *thisfunc = _findsigfunc(signame);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7580 char *thisname = signame;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7581 HWND thiswindow = window;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7582 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7583
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7584 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7585 if(GTK_IS_SCROLLED_WINDOW(thiswindow))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7586 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7587 thiswindow = (HWND)gtk_object_get_user_data(GTK_OBJECT(window));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7588 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7589
307
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
7590 if(GTK_IS_MENU_ITEM(thiswindow) && strcmp(signame, DW_SIGNAL_CLICKED) == 0)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7591 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7592 thisname = "activate";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7593 thisfunc = _findsigfunc(thisname);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7594 }
307
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
7595 else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_CONTEXT) == 0)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7596 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7597 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
7598 thisfunc = _findsigfunc(DW_SIGNAL_ITEM_CONTEXT);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7599 }
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
7600 #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
7601 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
7602 {
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7603 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
7604
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7605 work->window = window;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7606 work->data = data;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7607 work->func = sigfunc;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7608
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7609 gtk_signal_connect(GTK_OBJECT(thiswindow), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), work);
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7610 gtk_signal_connect(GTK_OBJECT(window), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), work);
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7611 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
7612 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
7613 }
307
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
7614 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
7615 {
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7616 work->window = window;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7617 work->data = data;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7618 work->func = sigfunc;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7619
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7620 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
7621 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
7622
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7623 g_signal_connect(G_OBJECT(thiswindow), thisname, (GCallback)thisfunc, work);
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7624 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
7625 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
7626 }
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7627 #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
7628 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
7629 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
7630 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
7631
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
7632 work->window = window;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
7633 work->data = data;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
7634 work->func = sigfunc;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
7635
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
7636 gtk_object_set_data(GTK_OBJECT(thiswindow), "container-context-func", (gpointer)thisfunc);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
7637 gtk_object_set_data(GTK_OBJECT(thiswindow), "container-context-data", (gpointer)work);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
7638 gtk_signal_connect(GTK_OBJECT(thiswindow), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), work);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
7639 gtk_signal_connect(GTK_OBJECT(window), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), work);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
7640 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
7641 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
7642 }
307
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
7643 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
7644 {
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7645 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
7646 {
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7647 gtk_object_set_data(GTK_OBJECT(thiswindow), "select-child-func", (gpointer)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
7648 gtk_object_set_data(GTK_OBJECT(thiswindow), "select-child-data", (gpointer)work);
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7649 }
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7650 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
7651 }
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7652 #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
7653 else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_ENTER) == 0)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7654 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7655 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
7656 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
7657 }
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
7658 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
7659 {
d35771f70bdd Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 163
diff changeset
7660 thisname = "select_row";
d35771f70bdd Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 163
diff changeset
7661 thisfunc = (void *)_container_select_row;
d35771f70bdd Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 163
diff changeset
7662 }
307
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
7663 else if(GTK_IS_COMBO(thiswindow) && strcmp(signame, DW_SIGNAL_LIST_SELECT) == 0)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7664 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7665 thisname = "select_child";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7666 thiswindow = GTK_COMBO(thiswindow)->list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7667 }
307
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
7668 else if(GTK_IS_LIST(thiswindow) && strcmp(signame, DW_SIGNAL_LIST_SELECT) == 0)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7669 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7670 thisname = "select_child";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7671 }
307
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
7672 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
7673 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
7674 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
7675 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
7676 thiswindow = GTK_COMBO(thiswindow)->entry;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
7677 }
307
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
7678 #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
7679 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
7680 {
b6948eac375a Sync with the latest dynamic windows, tree fixes, and other miscellaneous
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 54
diff changeset
7681 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
7682 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
7683 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
7684 }
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 #endif
205
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
7686 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
7687 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
7688 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
7689 thiswindow = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(thiswindow), "adjustment");
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
7690 }
331
20def3eaae8d Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 329
diff changeset
7691 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
7692 {
20def3eaae8d Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 329
diff changeset
7693 thisname = "switch-page";
20def3eaae8d Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 329
diff changeset
7694 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7695
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7696 if(!thisfunc || !thiswindow)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7697 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7698 free(work);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7699 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7700 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7701 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7702
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7703 work->window = window;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7704 work->data = data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7705 work->func = sigfunc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7706
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7707 gtk_signal_connect(GTK_OBJECT(thiswindow), thisname, GTK_SIGNAL_FUNC(thisfunc), work);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7708 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7709 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7710
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7711 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7712 * Removes callbacks for a given window with given name.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7713 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7714 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7715 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7716 void dw_signal_disconnect_by_name(HWND window, char *signame)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7717 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7718 #if 0
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7719 gtk_signal_disconnect_by_name(window, signame);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7720 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7721 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7722
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7723 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7724 * Removes all callbacks for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7725 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7726 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7727 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7728 void dw_signal_disconnect_by_window(HWND window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7729 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7730 #if 0
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7731 gtk_signal_disconnect_by_window(window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7732 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7733 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7734
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7735 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7736 * Removes all callbacks for a given window with specified data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7737 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7738 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7739 * data: Pointer to the data to be compared against.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7740 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7741 void dw_signal_disconnect_by_data(HWND window, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7742 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7743 dw_signal_disconnect_by_data(window, data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7744 }
153
a371875d5486 Sync up with the latest F/X sources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 151
diff changeset
7745