annotate gtk/dw.c @ 121:d8af32b1b1cd

Switch back to using pixmaps and bitmaps, only use pixbufs for doing XPM conversion.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 19 Oct 2002 21:48:57 +0000
parents 7d2108cbcd3e
children a05b6fb9c545
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 *
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
6 * (C) 2000-2002 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 char monthlist[][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
33 "Sep", "Oct", "Nov", "Dec" };
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
34 GdkColor _colors[] =
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
35 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
36 { 0, 0x0000, 0x0000, 0x0000 }, /* 0 black */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
37 { 0, 0xbbbb, 0x0000, 0x0000 }, /* 1 red */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
38 { 0, 0x0000, 0xbbbb, 0x0000 }, /* 2 green */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
39 { 0, 0xaaaa, 0xaaaa, 0x0000 }, /* 3 yellow */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
40 { 0, 0x0000, 0x0000, 0xcccc }, /* 4 blue */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
41 { 0, 0xbbbb, 0x0000, 0xbbbb }, /* 5 magenta */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
42 { 0, 0x0000, 0xbbbb, 0xbbbb }, /* 6 cyan */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
43 { 0, 0xaaaa, 0xaaaa, 0xaaaa }, /* 7 white */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
44 { 0, 0x7777, 0x7777, 0x7777 }, /* 8 grey */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
45 { 0, 0xffff, 0x0000, 0x0000 }, /* 9 bright red */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
46 { 0, 0x0000, 0xffff, 0x0000 }, /* 10 bright green */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
47 { 0, 0xeeee, 0xeeee, 0x0000 }, /* 11 bright yellow */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
48 { 0, 0x0000, 0x0000, 0xffff }, /* 12 bright blue */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
49 { 0, 0xffff, 0x0000, 0xffff }, /* 13 bright magenta */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
50 { 0, 0x0000, 0xeeee, 0xeeee }, /* 14 bright cyan */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
51 { 0, 0xffff, 0xffff, 0xffff }, /* 15 bright white */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
52 };
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
53
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
54 #define DW_THREAD_LIMIT 50
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
55
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
56 DWTID _dw_thread_list[DW_THREAD_LIMIT];
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
57 GdkColor _foreground[DW_THREAD_LIMIT];
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
58 GdkColor _background[DW_THREAD_LIMIT];
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
59
93
98cce029a611 Changed handling of menu item click events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 92
diff changeset
60 GtkWidget *last_window = NULL, *popup = NULL;
47
997e9ed670ef Fixes for box alignment problem on OS/2, crash in dw_bitmap_new() on unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 46
diff changeset
61
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
62 int _dw_file_active = 0, _dw_ignore_click = 0, _dw_unselecting = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
63 pthread_t _dw_thread = (pthread_t)-1;
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
64 int _dw_mutex_locked[DW_THREAD_LIMIT];
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
65 /* Use default border size for the default enlightenment theme */
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
66 int _dw_border_width = 12, _dw_border_height = 28;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
67
75
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 72
diff changeset
68 #define DW_MUTEX_LOCK { int index = _find_thread_index(dw_thread_id()); if(pthread_self() != _dw_thread && _dw_mutex_locked[index] == FALSE) { gdk_threads_enter(); _dw_mutex_locked[index] = TRUE; _locked_by_me = TRUE; } }
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 72
diff changeset
69 #define DW_MUTEX_UNLOCK { if(pthread_self() != _dw_thread && _locked_by_me == TRUE) { gdk_threads_leave(); _dw_mutex_locked[_find_thread_index(dw_thread_id())] = FALSE; _locked_by_me = FALSE; } }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
70
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
71 #define DEFAULT_SIZE_WIDTH 12
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
72 #define DEFAULT_SIZE_HEIGHT 6
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
73 #define DEFAULT_TITLEBAR_HEIGHT 22
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
74
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
75 GdkColormap *_dw_cmap = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
76
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
77 /* Signal forwarder prototypes */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
78 gint _button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
79 gint _button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
80 gint _motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gpointer data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
81 gint _delete_event(GtkWidget *widget, GdkEvent *event, gpointer data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
82 gint _key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
83 gint _generic_event(GtkWidget *widget, gpointer data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
84 gint _configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
85 void _activate_event(GtkWidget *widget, gpointer data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
86 void _container_select_event(GtkWidget *widget, GdkEventButton *event, gpointer data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
87 void _container_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
88 void _item_select_event(GtkWidget *widget, GtkWidget *child, gpointer data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
89 void _expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data);
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
90 void _set_focus_event(GtkWindow *window, GtkWidget *widget, gpointer data);
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
91 void _tree_select_event(GtkTree *tree, GtkWidget *child, 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
92 void _tree_context_event(GtkWidget *widget, GdkEventButton *event, 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
93 void _value_changed_event(GtkAdjustment *adjustment, gpointer user_data);
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
94
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
95
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
96 void msleep(long period);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
97
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
98 typedef struct
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
99 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
100 void *func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
101 char name[30];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
102
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
103 } SignalList;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
104
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
105 typedef struct
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
106 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
107 HWND window;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
108 void *func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
109 gpointer data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
110
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
111 } SignalHandler;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
112
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
113 #define SIGNALMAX 16
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
114
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
115 /* A list of signal forwarders, to account for paramater differences. */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
116 SignalList SignalTranslate[SIGNALMAX] = {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
117 { _configure_event, "configure_event" },
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
118 { _key_press_event, "key_press_event" },
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
119 { _button_press_event, "button_press_event" },
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
120 { _button_release_event, "button_release_event" },
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
121 { _motion_notify_event, "motion_notify_event" },
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
122 { _delete_event, "delete_event" },
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
123 { _expose_event, "expose_event" },
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
124 { _activate_event, "activate" },
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
125 { _generic_event, "clicked" },
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
126 { _container_select_event, "container-select" },
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
127 { _container_context_event, "container-context" },
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
128 { _tree_context_event, "tree-context" },
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
129 { _item_select_event, "item-select" },
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
130 { _tree_select_event, "tree-select" },
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
131 { _set_focus_event, "set-focus" },
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
132 { _value_changed_event, "value_changed" }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
133 };
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
134
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
135 /* Alignment flags */
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
136 #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
137 #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
138 #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
139
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
140 /* Finds the translation function for a given signal name */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
141 void *_findsigfunc(char *signame)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
142 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
143 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
144
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
145 for(z=0;z<SIGNALMAX;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
146 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
147 if(strcasecmp(signame, SignalTranslate[z].name) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
148 return SignalTranslate[z].func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
149 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
150 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
151 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
152
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
153 void _set_focus_event(GtkWindow *window, GtkWidget *widget, gpointer data)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
154 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
155 SignalHandler *work = (SignalHandler *)data;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
156
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
157 if(work)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
158 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
159 int (*setfocusfunc)(HWND, void *) = work->func;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
160
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
161 setfocusfunc((HWND)window, work->data);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
162 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
163 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
164
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
165 gint _button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
166 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
167 SignalHandler *work = (SignalHandler *)data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
168
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
169 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
170 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
171 int (*buttonfunc)(HWND, int, int, int, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
172 int mybutton = event->button;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
173
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
174 if(event->button == 3)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
175 mybutton = 2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
176 else if(event->button == 2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
177 mybutton = 3;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
178
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
179 buttonfunc(widget, event->x, event->y, mybutton, work->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
180 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
181 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
182 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
183
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
184 gint _button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
185 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
186 SignalHandler *work = (SignalHandler *)data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
187
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
188 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
189 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
190 int (*buttonfunc)(HWND, int, int, int, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
191 int mybutton = event->button;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
192
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
193 if(event->button == 3)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
194 mybutton = 2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
195 else if(event->button == 2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
196 mybutton = 3;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
197
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
198 buttonfunc(widget, event->x, event->y, mybutton, work->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
199 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
200 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
201 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
202
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
203 gint _motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gpointer data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
204 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
205 SignalHandler *work = (SignalHandler *)data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
206
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
207 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
208 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
209 int (*motionfunc)(HWND, int, int, int, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
210 int keys = 0, x, y;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
211 GdkModifierType state;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
212
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
213 if (event->is_hint)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
214 gdk_window_get_pointer (event->window, &x, &y, &state);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
215 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
216 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
217 x = event->x;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
218 y = event->y;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
219 state = event->state;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
220 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
221
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
222 if (state & GDK_BUTTON1_MASK)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
223 keys = DW_BUTTON1_MASK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
224 if (state & GDK_BUTTON3_MASK)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
225 keys |= DW_BUTTON2_MASK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
226 if (state & GDK_BUTTON2_MASK)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
227 keys |= DW_BUTTON3_MASK;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
228
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
229 motionfunc(widget, x, y, keys, work->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
230 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
231 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
232 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
233
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
234 gint _delete_event(GtkWidget *widget, GdkEvent *event, gpointer data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
235 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
236 SignalHandler *work = (SignalHandler *)data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
237
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
238 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
239 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
240 int (*closefunc)(HWND, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
241
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
242 closefunc(widget, work->data);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
243 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
244 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
245 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
246
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
247 gint _key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
248 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
249 SignalHandler *work = (SignalHandler *)data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
250
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
251 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
252 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
253 int (*keypressfunc)(HWND, int, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
254
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
255 keypressfunc(widget, *event->string, work->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
256 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
257 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
258 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
259
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
260 gint _generic_event(GtkWidget *widget, gpointer data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
261 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
262 SignalHandler *work = (SignalHandler *)data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
263
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
264 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
265 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
266 int (*genericfunc)(HWND, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
267
94
7c3eef54c98c Popup menu handler fix for GTK, and fixed sliders/percent widgets not
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
268 genericfunc(widget, work->data);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
269 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
270 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
271 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
272
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
273 void _activate_event(GtkWidget *widget, gpointer data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
274 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
275 SignalHandler *work = (SignalHandler *)data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
276
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
277 if(work && !_dw_ignore_click)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
278 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
279 void (*activatefunc)(HWND, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
280
94
7c3eef54c98c Popup menu handler fix for GTK, and fixed sliders/percent widgets not
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
281 activatefunc(popup ? popup : work->window, work->data);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
282 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
283 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
284 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
285
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
286 gint _configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
287 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
288 SignalHandler *work = (SignalHandler *)data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
289
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
290 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
291 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
292 int (*sizefunc)(HWND, int, int, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
293
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
294 sizefunc(widget, event->width, event->height, work->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
295 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
296 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
297 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
298
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
299 void _expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
300 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
301 SignalHandler *work = (SignalHandler *)data;
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 DWExpose exp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
306 int (*exposefunc)(HWND, DWExpose *, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
307
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
308 exp.x = event->area.x;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
309 exp.y = event->area.y;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
310 exp.width = event->area.width;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
311 exp.height = event->area.height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
312 exposefunc(widget, &exp, work->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
313 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
314 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
315
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
316 void _item_select_event(GtkWidget *widget, GtkWidget *child, gpointer data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
317 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
318 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
319 static int _dw_recursing = 0;
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
320
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
321 if(_dw_recursing)
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
322 return;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
323
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
324 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
325 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
326 int (*selectfunc)(HWND, int, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
327 GList *list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
328 int item = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
329
39
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
330 _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
331
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
332 if(GTK_IS_COMBO(work->window))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
333 list = GTK_LIST(GTK_COMBO(work->window)->list)->children;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
334 else if(GTK_IS_LIST(widget))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
335 list = GTK_LIST(widget)->children;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
336 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
337 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
338
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
339 while(list)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
340 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
341 if(list->data == (gpointer)child)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
342 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
343 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
344 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
345 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
346 if(selectfunc)
2d121d4d90c0 Run the _item_select_event() handler on comboboxes even if a handler
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 114
diff changeset
347 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
348 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
349 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
350 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
351 item++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
352 list = list->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
353 }
39
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
354 _dw_recursing = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
355 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
356 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
357
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
358 void _container_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
359 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
360 SignalHandler *work = (SignalHandler *)data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
361
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
362 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
363 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
364 if(event->button == 3)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
365 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
366 void (*contextfunc)(HWND, char *, int, int, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
367 char *text;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
368 int row, col;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
369
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
370 gtk_clist_get_selection_info(GTK_CLIST(widget), event->x, event->y, &row, &col);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
371
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
372 text = (char *)gtk_clist_get_row_data(GTK_CLIST(widget), row);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
373 contextfunc(work->window, text, event->x, event->y, work->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
374 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
375 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
376 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
377
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
378 void _tree_context_event(GtkWidget *widget, GdkEventButton *event, gpointer 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
379 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
380 SignalHandler *work = (SignalHandler *)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
381
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
382 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
383 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
384 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
385 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
386 void (*contextfunc)(HWND, char *, int, int, void *, void *) = work->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
387 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
388 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
389
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
390 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
391 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
392 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
393
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
394 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
395 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
396 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
397
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
398 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
399 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
400 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
401 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
402 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
403 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
404 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
405
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
406 contextfunc(work->window, text, event->x, event->y, work->data, 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
407 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
408 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
409 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
410
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
411 void _tree_select_event(GtkTree *tree, GtkWidget *child, gpointer data)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
412 {
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
413 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
414 GtkWidget *treeroot = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(child), "tree");
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
415
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
416 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
417 {
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
418 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
419 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
420 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
421 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
422 }
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
423
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
424 if(work)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
425 {
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 void (*treeselectfunc)(HWND, HWND, char *, void *, void *) = work->func;
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
427 char *text = (char *)gtk_object_get_data(GTK_OBJECT(child), "text");
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
428 void *itemdata = (char *)gtk_object_get_data(GTK_OBJECT(child), "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
429 treeselectfunc(work->window, child, text, itemdata, work->data);
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
430 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
431 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
432
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
433 void _container_select_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
434 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
435 SignalHandler *work = (SignalHandler *)data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
436
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
437 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
438 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
439 if(event->button == 1 && event->type == GDK_2BUTTON_PRESS)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
440 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
441 void (*contextfunc)(HWND, char *, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
442 char *text;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
443 int row, col;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
444
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
445 gtk_clist_get_selection_info(GTK_CLIST(widget), event->x, event->y, &row, &col);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
446
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
447 text = (char *)gtk_clist_get_row_data(GTK_CLIST(widget), row);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
448 contextfunc(work->window, text, work->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
449 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
450 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
451 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
452
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
453 void _select_row(GtkWidget *widget, gint row, gint column, GdkEventButton *event, gpointer data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
454 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
455 GList *tmp = (GList *)gtk_object_get_data(GTK_OBJECT(widget), "selectlist");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
456 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
457 int multi = (int)gtk_object_get_data(GTK_OBJECT(widget), "multi");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
458
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
459 if(rowdata)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
460 {
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
461 if(!multi)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
462 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
463 g_list_free(tmp);
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
464 tmp = NULL;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
465 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
466
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
467 tmp = g_list_append(tmp, rowdata);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
468 gtk_object_set_data(GTK_OBJECT(widget), "selectlist", tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
469 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
470
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
471 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
472
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
473 void _unselect_row(GtkWidget *widget, gint row, gint column, GdkEventButton *event, gpointer data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
474 {
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
475 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
476 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
477
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 72
diff changeset
478 if(_dw_unselecting)
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 72
diff changeset
479 return;
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 72
diff changeset
480
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 72
diff changeset
481 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
482 rowdata = gtk_clist_get_row_data(GTK_CLIST(widget), row);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
483
76
ce0f5528bab0 Fixed clist crashing problems on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 75
diff changeset
484 if(rowdata && tmp)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
485 {
76
ce0f5528bab0 Fixed clist crashing problems on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 75
diff changeset
486 tmp = g_list_remove(tmp, rowdata);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
487 gtk_object_set_data(GTK_OBJECT(widget), "selectlist", tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
488 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
489 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
490
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
491 int _round_value(gfloat val)
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
492 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
493 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
494
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
495 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
496 newval++;
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
497
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
498 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
499 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
500
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
501 void _value_changed_event(GtkAdjustment *adjustment, gpointer data)
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
502 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
503 GtkWidget *slider = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(adjustment), "slider");
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
504 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
505
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
506 if(slider && work)
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
507 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
508 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
509 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
510 int val = _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
511 static int lastval = -1;
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
512 static GtkWidget *lastwidget = 0;
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
513
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
514 if(lastval != val || lastwidget != slider)
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
515 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
516 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
517 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
518 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
519 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
520 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
521 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
522 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
523
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
524 gint _default_key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
525 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
526 GtkWidget *next = (GtkWidget *)data;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
527
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
528 if(next)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
529 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
530 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
531 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
532 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
533 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
534 else
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
535 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
536 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
537 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
538 return TRUE;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
539 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
540
121
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
541 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
542 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
543 char *data = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
544 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
545
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
546 for(z=0;z<_resources.resource_max;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
547 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
548 if(_resources.resource_id[z] == id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
549 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
550 data = _resources.resource_data[z];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
551 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
552 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
553 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
554
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
555 if(data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
556 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
557 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
558 #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
559 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
560
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
561 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
562 *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
563 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
564 *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
565
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
566 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
567 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
568 #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
569 gdk_imlib_data_to_pixmap((char **)data, &icon_pixmap, bitmap);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
570 #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
571 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
572 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
573 return icon_pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
574 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
575 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
576 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
577
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
578 void _size_allocate(GtkWindow *window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
579 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
580 XSizeHints sizehints;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
581
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
582 sizehints.base_width = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
583 sizehints.base_height = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
584 sizehints.width_inc = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
585 sizehints.height_inc = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
586 sizehints.min_width = 8;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
587 sizehints.min_height = 8;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
588
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
589 sizehints.flags = (PBaseSize|PMinSize|PResizeInc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
590
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
591 XSetWMNormalHints (GDK_DISPLAY(),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
592 GDK_WINDOW_XWINDOW (GTK_WIDGET (window)->window),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
593 &sizehints);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
594 gdk_flush ();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
595 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
596
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
597 /* Find the index of a given thread */
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
598 int _find_thread_index(DWTID tid)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
599 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
600 int z;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
601
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
602 for(z=0;z<DW_THREAD_LIMIT;z++)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
603 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
604 if(_dw_thread_list[z] == tid)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
605 return z;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
606 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
607 return 0;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
608 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
609
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
610 /* Add a thread id to the thread list */
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
611 void _dw_thread_add(DWTID tid)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
612 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
613 int z;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
614
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
615 for(z=0;z<DW_THREAD_LIMIT;z++)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
616 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
617 if(_dw_thread_list[z] == (DWTID)-1)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
618 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
619 _dw_thread_list[z] = tid;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
620 _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
621 _background[z].pixel = 0;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
622 _background[z].red = 0xaaaa;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
623 _background[z].green = 0xaaaa;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
624 _background[z].blue = 0xaaaa;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
625 return;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
626 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
627 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
628 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
629
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
630 /* Remove a thread id to the thread list */
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
631 void _dw_thread_remove(DWTID tid)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
632 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
633 int z;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
634
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
635 for(z=0;z<DW_THREAD_LIMIT;z++)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
636 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
637 if(_dw_thread_list[z] == (DWTID)tid)
51
d97de82f0b6e Fix warning on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 49
diff changeset
638 _dw_thread_list[z] = (DWTID)-1;
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
639 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
640 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
641
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
642 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
643 * Initializes the Dynamic Windows engine.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
644 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
645 * newthread: True if this is the only thread.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
646 * False if there is already a message loop running.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
647 */
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
648 int dw_int_init(DWResources *res, int newthread, int argc, char *argv[])
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
649 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
650 int z;
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
651 char *tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
652
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
653 if(res)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
654 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
655 _resources.resource_max = res->resource_max;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
656 _resources.resource_id = res->resource_id;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
657 _resources.resource_data = res->resource_data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
658 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
659 gtk_set_locale();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
660 g_thread_init(NULL);
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
661
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
662 gtk_init(&argc, &argv);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
663 #ifdef USE_IMLIB
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
664 gdk_imlib_init();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
665 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
666 /* Add colors to the system colormap */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
667 _dw_cmap = gdk_colormap_get_system();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
668 for(z=0;z<16;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
669 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
670
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
671 tmp = getenv("DW_BORDER_WIDTH");
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
672 if(tmp)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
673 _dw_border_width = atoi(tmp);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
674 tmp = getenv("DW_BORDER_HEIGHT");
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
675 if(tmp)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
676 _dw_border_height = atoi(tmp);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
677
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
678 for(z=0;z<DW_THREAD_LIMIT;z++)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
679 _dw_thread_list[z] = (DWTID)-1;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
680
77
002da4d18ac6 Set tooltip background color to yellow.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 76
diff changeset
681 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
682
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
683 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
684 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
685
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
686 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
687 * Runs a message loop for Dynamic Windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
688 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
689 * currenthab: The handle to the current anchor block
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
690 * or NULL if this DW is handling the message loop.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
691 * func: Function pointer to the message filter function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
692 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
693 void dw_main(HAB currenthab, void *func)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
694 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
695 _dw_thread = pthread_self();
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
696 _dw_thread_add(_dw_thread);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
697 gdk_threads_enter();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
698 gtk_main();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
699 gdk_threads_leave();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
700 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
701
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
702 /*
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
703 * 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
704 * 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
705 * 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
706 */
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
707 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
708 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
709 struct timeval tv, start;
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
710
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
711 gettimeofday(&start, NULL);
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
712
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
713 if(_dw_thread == (pthread_t)-1 || _dw_thread == pthread_self())
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
714 {
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
715 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
716
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
717 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
718 {
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
719 gdk_threads_enter();
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
720 if(gtk_events_pending())
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
721 gtk_main_iteration();
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
722 else
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
723 msleep(1);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
724 gdk_threads_leave();
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
725 gettimeofday(&tv, NULL);
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
726 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
727 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
728 else
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
729 msleep(milliseconds);
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
730 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
731
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
732 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
733 * Free's memory allocated by dynamic windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
734 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
735 * ptr: Pointer to dynamic windows allocated
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
736 * memory to be free()'d.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
737 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
738 void dw_free(void *ptr)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
739 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
740 free(ptr);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
741 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
742
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
743 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
744 * Allocates and initializes a dialog struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
745 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
746 * data: User defined data to be passed to functions.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
747 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
748 DWDialog *dw_dialog_new(void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
749 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
750 DWDialog *tmp = malloc(sizeof(DWDialog));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
751
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
752 tmp->eve = dw_event_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
753 dw_event_reset(tmp->eve);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
754 tmp->data = data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
755 tmp->done = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
756 tmp->result = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
757
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
758 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
759 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
760
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
761 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
762 * Accepts a dialog struct and returns the given data to the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
763 * initial called of dw_dialog_wait().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
764 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
765 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
766 * result: Data to be returned by dw_dialog_wait().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
767 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
768 int dw_dialog_dismiss(DWDialog *dialog, void *result)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
769 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
770 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
771 if(pthread_self() == _dw_thread || _dw_thread == (pthread_t)-1)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
772 gtk_main_quit();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
773 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
774 dw_event_post(dialog->eve);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
775 dialog->done = TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
776 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
777 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
778
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
779 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
780 * Accepts a dialog struct waits for dw_dialog_dismiss() to be
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
781 * called by a signal handler with the given dialog struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
782 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
783 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
784 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
785 void *dw_dialog_wait(DWDialog *dialog)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
786 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
787 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
788 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
789
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
790 /* _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
791 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
792 {
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
793 _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
794 newprocess = 1;
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
795 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
796 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
797
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
798 if(pthread_self() == _dw_thread)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
799 gtk_main();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
800 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
801 dw_event_wait(dialog->eve, -1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
802
41
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
803 if(newprocess)
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
804 {
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
805 _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
806 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
807 }
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
808
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
809 dw_event_close(&dialog->eve);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
810 tmp = dialog->result;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
811 free(dialog);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
812 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
813 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
814
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
815 void _delete(GtkWidget *widget, GtkWidget *event, gpointer param)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
816 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
817 gtk_widget_destroy(GTK_WIDGET(param));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
818 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
819
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
820 void _delete2(GtkWidget *widget, gpointer param)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
821 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
822 gtk_widget_destroy(GTK_WIDGET(param));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
823 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
824
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
825
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
826 void _dw_ok_func(HWND window, void *data)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
827 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
828 DWDialog *dwwait = (DWDialog *)data;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
829
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
830 if(!dwwait)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
831 return;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
832
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
833 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
834 dw_dialog_dismiss((DWDialog *)data, (void *)0);
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
835 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
836
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
837 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
838 * Displays a Message Box with given text and title..
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
839 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
840 * title: The title of the message box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
841 * format: printf style format string.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
842 * ...: Additional variables for use in the format.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
843 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
844 int dw_messagebox(char *title, char *format, ...)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
845 {
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
846 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
847 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
848 DWDialog *dwwait;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
849 va_list args;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
850 char outbuf[256];
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
851 int x, y;
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
852
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
853 va_start(args, format);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
854 vsprintf(outbuf, format, args);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
855 va_end(args);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
856
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
857 entrywindow = dw_window_new(HWND_DESKTOP, title, flStyle);
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
858 mainbox = dw_box_new(BOXVERT, 10);
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
859 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
860
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
861 /* Archive Name */
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
862 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
863 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
864
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
865 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
866
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
867 /* Buttons */
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
868 buttonbox = dw_box_new(BOXHORZ, 10);
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
869
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
870 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
871
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
872 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
873
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
874 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
875
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
876 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
877
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
878 dw_signal_connect(okbutton, "clicked", DW_SIGNAL_FUNC(_dw_ok_func), (void *)dwwait);
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
879
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
880 x = (dw_screen_width() - 220)/2;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
881 y = (dw_screen_height() - 110)/2;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
882
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
883 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
884
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
885 dw_window_show(entrywindow);
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
886
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
887 dw_dialog_wait(dwwait);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
888
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
889 return strlen(outbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
890 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
891
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
892 void _dw_yes_func(HWND window, void *data)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
893 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
894 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
895
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
896 if(!dwwait)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
897 return;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
898
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
899 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
900 dw_dialog_dismiss((DWDialog *)data, (void *)1);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
901 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
902
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
903 void _dw_no_func(HWND window, void *data)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
904 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
905 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
906
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
907 if(!dwwait)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
908 return;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
909
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
910 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
911 dw_dialog_dismiss((DWDialog *)data, (void *)0);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
912 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
913
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
914 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
915 * Displays a Message Box with given text and title..
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
916 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
917 * title: The title of the message box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
918 * text: The text to display in the box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
919 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
920 * True if YES False of NO.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
921 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
922 int dw_yesno(char *title, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
923 {
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
924 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
925 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
926 DWDialog *dwwait;
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
927 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
928
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
929 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
930
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
931 mainbox = dw_box_new(BOXVERT, 10);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
932
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
933 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
934
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
935 /* 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
936 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
937 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
938
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
939 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
940
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
941 /* Buttons */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
942 buttonbox = dw_box_new(BOXHORZ, 10);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
943
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
944 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
945
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
946 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
947
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
948 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
949
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
950 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
951
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
952 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
953
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
954 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
955
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
956 dw_signal_connect(yesbutton, "clicked", DW_SIGNAL_FUNC(_dw_yes_func), (void *)dwwait);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
957 dw_signal_connect(nobutton, "clicked", DW_SIGNAL_FUNC(_dw_no_func), (void *)dwwait);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
958
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
959 x = (dw_screen_width() - 220)/2;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
960 y = (dw_screen_height() - 110)/2;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
961
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
962 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
963
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
964 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
965
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
966 return (int)dw_dialog_wait(dwwait);;
3
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 /*
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
970 * 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
971 * Parameters:
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
972 * handle: The window handle to minimize.
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
973 */
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
974 int dw_window_minimize(HWND handle)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
975 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
976 int _locked_by_me = FALSE;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
977
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
978 if(!handle)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
979 return 0;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
980
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
981 DW_MUTEX_LOCK;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
982 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
983 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
984 DefaultScreen (GDK_DISPLAY ()));
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
985 DW_MUTEX_UNLOCK;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
986 return 0;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
987 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
988
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
989 /*
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
990 * Makes the window topmost.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
991 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
992 * 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
993 */
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
994 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
995 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
996 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
997
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
998 if(!handle)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
999 return 0;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1000
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1001 DW_MUTEX_LOCK;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1002 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
1003 DW_MUTEX_UNLOCK;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1004 return 0;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1005 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1006
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1007 /*
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1008 * Makes the window bottommost.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1009 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1010 * 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
1011 */
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1012 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
1013 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1014 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
1015
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1016 if(!handle)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1017 return 0;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1018
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1019 DW_MUTEX_LOCK;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1020 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
1021 DW_MUTEX_UNLOCK;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1022 return 0;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1023 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1024
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1025 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1026 * Makes the window visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1027 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1028 * handle: The window handle to make visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1029 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1030 int dw_window_show(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1031 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1032 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
1033 GtkWidget *defaultitem;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1034
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1035 if(!handle)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1036 return 0;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1037
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1038 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1039 gtk_widget_show(handle);
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1040 if(GTK_WIDGET(handle)->window)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1041 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1042 gdk_window_raise(GTK_WIDGET(handle)->window);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1043 gdk_flush();
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1044 gdk_window_show(GTK_WIDGET(handle)->window);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1045 gdk_flush();
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1046 }
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
1047 defaultitem = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "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
1048 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
1049 gtk_widget_grab_focus(defaultitem);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1050 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1051 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1052 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1053
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1054 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1055 * Makes the window invisible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1056 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1057 * handle: The window handle to make visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1058 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1059 int dw_window_hide(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1060 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1061 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1062
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1063 if(!handle)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1064 return 0;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1065
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1066 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1067 gtk_widget_hide(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1068 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1069 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1070 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1071
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1072 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1073 * Destroys a window and all of it's children.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1074 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1075 * handle: The window handle to destroy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1076 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1077 int dw_window_destroy(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1078 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1079 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1080
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1081 if(!handle)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1082 return 0;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1083
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1084 DW_MUTEX_LOCK;
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
1085 if(GTK_IS_WIDGET(handle))
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
1086 gtk_widget_destroy(handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1087 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1088 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1089 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1090
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
1091 /* 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
1092 * 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
1093 * 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
1094 */
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1095 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
1096 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1097 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1098
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1099 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1100 * Changes a window's parent to newparent.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1101 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1102 * handle: The window handle to destroy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1103 * newparent: The window's new parent window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1104 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1105 void dw_window_reparent(HWND handle, HWND newparent)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1106 {
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1107 int _locked_by_me = FALSE;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1108
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1109 DW_MUTEX_LOCK;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1110 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
1111 DW_MUTEX_UNLOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1112 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1113
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1114 int _set_font(HWND handle, char *fontname)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1115 {
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
1116 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
1117 #if GTK_MAJOR_VERSION < 2
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1118 GtkStyle *style;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1119 GdkFont *font = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1120
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1121 font = gdk_font_load(fontname);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1122
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1123 if(font)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1124 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1125 style = gtk_widget_get_style(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1126 style->font = font;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1127 gtk_widget_set_style(handle, style);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1128 retval = TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1129 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
1130 #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
1131 PangoFontDescription *font = pango_font_description_from_string(fontname);
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
1132
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
1133 if(font)
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
1134 gtk_widget_modify_font(handle, font);
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
1135 pango_font_description_free(font);
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
1136 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1137 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1138 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1139
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1140 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1141 * Sets the font used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1142 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1143 * handle: The window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1144 * fontname: Name and size of the font in the form "size.fontname"
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1145 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1146 int dw_window_set_font(HWND handle, char *fontname)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1147 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1148 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1149 char *font;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1150 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1151 gpointer data;
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1152 GdkFont *gdkfont;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1153
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1154 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1155 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1156 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1157 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1158 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1159 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1160 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1161 font = strdup(fontname);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1162
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1163 /* 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
1164 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
1165 if(gdkfont)
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1166 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
1167 gdkfont = gdk_font_load(fontname);
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1168 gtk_object_set_data(GTK_OBJECT(handle2), "gdkfont", (gpointer)gdkfont);
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1169
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1170 /* Free old font name if one is allocated */
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1171 data = gtk_object_get_data(GTK_OBJECT(handle2), "fontname");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1172 if(data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1173 free(data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1174
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1175 if(font)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1176 gtk_object_set_data(GTK_OBJECT(handle2), "fontname", (gpointer)font);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1177
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1178
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1179 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1180 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1181 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1182
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1183 void _free_gdk_colors(HWND handle)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1184 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1185 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
1186
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1187 if(old)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1188 free(old);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1189
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1190 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
1191
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1192 if(old)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1193 free(old);
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
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1196 /* Free old color pointers and allocate new ones */
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1197 void _save_gdk_colors(HWND handle, GdkColor fore, GdkColor back)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1198 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1199 GdkColor *foregdk = malloc(sizeof(GdkColor));
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1200 GdkColor *backgdk = malloc(sizeof(GdkColor));
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1201
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1202 _free_gdk_colors(handle);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1203
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1204 *foregdk = fore;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1205 *backgdk = back;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1206
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1207 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
1208 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
1209 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1210
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1211 int _set_color(HWND handle, unsigned long fore, unsigned long back)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1212 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1213 GtkStyle *style;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1214
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1215 if(fore & DW_RGB_COLOR || back & DW_RGB_COLOR)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1216 {
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1217 /* Remember that each color component in X11 use 16 bit no matter
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1218 * what the destination display supports. (and thus GDK)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1219 */
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1220 GdkColor forecolor = { 0, DW_RED_VALUE(fore) << 8, DW_GREEN_VALUE(fore) << 8, DW_BLUE_VALUE(fore) << 8 };
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1221 GdkColor backcolor = { 0, DW_RED_VALUE(back) << 8, DW_GREEN_VALUE(back) << 8, DW_BLUE_VALUE(back) << 8 };
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1222
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1223 gdk_color_alloc(_dw_cmap, &forecolor);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1224 gdk_color_alloc(_dw_cmap, &backcolor);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1225
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1226 style = gtk_style_copy(gtk_widget_get_style(handle));
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1227 style->text[0] = style->text[1] = style->fg[0] = style->fg[1] = forecolor;
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1228 style->base[0] = style->base[1] = style->bg[0] = style->bg[1] = backcolor;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1229 gtk_widget_set_style(handle, style);
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
1230
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1231 _save_gdk_colors(handle, forecolor, backcolor);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1232
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1233 if(GTK_IS_CLIST(handle))
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1234 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1235 int z, rowcount = (int)gtk_object_get_data(GTK_OBJECT(handle), "rowcount");
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1236
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1237 for(z=0;z<rowcount;z++)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1238 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1239 gtk_clist_set_foreground(GTK_CLIST(handle), z, &forecolor);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1240 gtk_clist_set_background(GTK_CLIST(handle), z, &backcolor);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1241 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1242 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1243 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1244 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1245 {
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1246 style = gtk_style_copy(gtk_widget_get_style(handle));
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1247 style->text[0] = style->text[1] = style->fg[0] = style->fg[1] = _colors[fore];
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1248 style->base[0] = style->base[1] = style->bg[0] = style->bg[1] = _colors[back];
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1249 gtk_widget_set_style(handle, style);
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1250
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1251 _save_gdk_colors(handle, _colors[fore], _colors[back]);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1252
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1253 if(GTK_IS_CLIST(handle))
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1254 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1255 int z, rowcount = (int)gtk_object_get_data(GTK_OBJECT(handle), "rowcount");
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1256
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1257 for(z=0;z<rowcount;z++)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1258 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1259 gtk_clist_set_foreground(GTK_CLIST(handle), z, &_colors[fore]);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1260 gtk_clist_set_background(GTK_CLIST(handle), z, &_colors[back]);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1261 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1262 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1263 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1264
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1265 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1266 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1267 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1268 * Sets the colors used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1269 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1270 * handle: The window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1271 * fore: Foreground color in RGB format.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1272 * back: Background color in RGB format.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1273 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1274 int dw_window_set_color(HWND handle, unsigned long fore, unsigned long back)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1275 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1276 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1277 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1278
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1279 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1280
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1281 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1282 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1283 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1284 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1285 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1286 }
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1287 else if(GTK_IS_BOX(handle))
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1288 {
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1289 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1290 if(tmp)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1291 handle2 = tmp;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1292 }
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1293 else if(GTK_IS_TABLE(handle))
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1294 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1295 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
1296 if(tmp)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1297 handle2 = tmp;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1298 }
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1299
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1300 _set_color(handle2, fore, back);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1301
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1302 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1303 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1304 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1305
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1306 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1307 * Sets the font used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1308 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1309 * handle: The window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1310 * border: Size of the window border in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1311 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1312 int dw_window_set_border(HWND handle, int border)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1313 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1314 /* TODO */
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
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1318 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1319 * Captures the mouse input to this window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1320 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1321 * handle: Handle to receive mouse input.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1322 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1323 void dw_window_capture(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1324 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1325 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1326
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1327 DW_MUTEX_LOCK;
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1328 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
1329 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1330 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1331
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1332 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1333 * 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
1334 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1335 * 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
1336 * 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
1337 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1338 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
1339 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
1340 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
1341 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
1342
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
1343 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
1344 cursor = gdk_cursor_new(pointertype);
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1345 if(handle && handle->window)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1346 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
1347 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
1348 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
1349 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1350
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1351 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1352 * Releases previous mouse capture.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1353 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1354 void dw_window_release(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1355 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1356 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1357
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1358 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1359 gdk_pointer_ungrab(GDK_CURRENT_TIME);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1360 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1361 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1362
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1363 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1364 * Create a new Window Frame.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1365 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1366 * owner: The Owner's window handle or HWND_DESKTOP.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1367 * title: The Window title.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1368 * flStyle: Style flags, see the PM reference.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1369 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1370 HWND dw_window_new(HWND hwndOwner, char *title, unsigned long flStyle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1371 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1372 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1373 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
1374 int flags = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1375
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1376 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
1377 last_window = tmp = gtk_window_new(GTK_WINDOW_TOPLEVEL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1378
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1379 gtk_window_set_title(GTK_WINDOW(tmp), title);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1380 if(!(flStyle & DW_FCF_SIZEBORDER))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1381 gtk_window_set_policy(GTK_WINDOW(tmp), FALSE, FALSE, TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1382
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1383 gtk_widget_realize(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1384
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1385 if(flStyle & DW_FCF_TITLEBAR)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1386 flags |= GDK_DECOR_TITLE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1387
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1388 if(flStyle & DW_FCF_MINMAX)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1389 flags |= GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1390
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1391 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
1392 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
1393
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
1394 if(flStyle & DW_FCF_BORDER || flStyle & DW_FCF_DLGBORDER)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1395 flags |= GDK_DECOR_BORDER;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1396
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1397 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
1398
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1399 if(hwndOwner)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1400 gdk_window_reparent(GTK_WIDGET(tmp)->window, GTK_WIDGET(hwndOwner)->window, 0, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1401
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1402 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1403 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1404 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1405
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1406 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1407 * Create a new Box to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1408 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1409 * type: Either BOXVERT (vertical) or BOXHORZ (horizontal).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1410 * pad: Number of pixels to pad around the box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1411 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1412 HWND dw_box_new(int type, int pad)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1413 {
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1414 GtkWidget *tmp, *eventbox;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1415 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1416
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1417 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
1418 tmp = gtk_table_new(1, 1, FALSE);
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1419 eventbox = gtk_event_box_new();
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1420
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1421 gtk_widget_show(eventbox);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1422 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
1423 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
1424 gtk_object_set_data(GTK_OBJECT(tmp), "boxpad", (gpointer)pad);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1425 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1426 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1427 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1428 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1429
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1430 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1431 * Create a new Group Box to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1432 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1433 * type: Either BOXVERT (vertical) or BOXHORZ (horizontal).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1434 * pad: Number of pixels to pad around the box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1435 * title: Text to be displayined in the group outline.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1436 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1437 HWND dw_groupbox_new(int type, int pad, char *title)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1438 {
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1439 GtkWidget *tmp, *frame;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1440 int _locked_by_me = FALSE;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1441
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1442 DW_MUTEX_LOCK;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1443 frame = gtk_frame_new(NULL);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1444 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
1445 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
1446 tmp = gtk_table_new(1, 1, FALSE);
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1447 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
1448 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
1449 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
1450 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
1451 gtk_container_add(GTK_CONTAINER(frame), tmp);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1452 gtk_widget_show(tmp);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1453 gtk_widget_show(frame);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1454 DW_MUTEX_UNLOCK;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1455 return frame;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1456 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1457
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1458 /*
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1459 * 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
1460 * Parameters:
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1461 * 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
1462 */
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1463 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
1464 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
1465 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
1466 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
1467
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
1468 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
1469 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
1470 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
1471 return tmp;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1472 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1473
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1474 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1475 * Create a bitmap object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1476 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1477 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1478 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1479 HWND dw_bitmap_new(unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1480 {
121
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
1481 #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
1482 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
1483 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
1484 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
1485 "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
1486 " 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
1487 ". 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
1488 "."};
121
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
1489 #endif
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
1490 GtkWidget *tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1491 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1492
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1493 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
1494 #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
1495 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
1496 #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
1497 gdk_imlib_data_to_pixmap(test_xpm, &pixmap, &bitmap);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1498 #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
1499 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
1500
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
1501 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
1502 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
1503 #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
1504 #if GTK_MAJOR_VERSION < 2
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1505 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
1506 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1507 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1508 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1509 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1510 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1511 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1512
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1513 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1514 * Create a notebook object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1515 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1516 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1517 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1518 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1519 HWND dw_notebook_new(unsigned long id, int top)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1520 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
1521 GtkWidget *tmp, **pagearray = calloc(sizeof(GtkWidget *), 256);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1522 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1523
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1524 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1525 tmp = gtk_notebook_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1526 if(top)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1527 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(tmp), GTK_POS_TOP);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1528 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1529 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
1530 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
1531 #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
1532 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
1533 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1534 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1535 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
1536 gtk_object_set_data(GTK_OBJECT(tmp), "pagearray", (gpointer)pagearray);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1537 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1538 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1539 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1540
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1541 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1542 * Create a menu object to be popped up.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1543 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1544 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1545 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1546 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1547 HMENUI dw_menu_new(unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1548 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1549 int _locked_by_me = FALSE;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1550 HMENUI tmp = malloc(sizeof(struct _hmenui));
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1551 GtkAccelGroup *accel_group;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1552
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1553 if(!tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1554 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1555
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1556 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1557 tmp->menu = gtk_menu_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1558 gtk_widget_show(tmp->menu);
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1559 accel_group = gtk_accel_group_new();
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1560 gtk_object_set_data(GTK_OBJECT(tmp->menu), "id", (gpointer)id);
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1561 gtk_object_set_data(GTK_OBJECT(tmp->menu), "accel", (gpointer)accel_group);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1562 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1563 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1564 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1565
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1566 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1567 * Create a menubar on a window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1568 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1569 * location: Handle of a window frame to be attached to.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1570 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1571 HMENUI dw_menubar_new(HWND location)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1572 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1573 GtkWidget *box;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1574 int _locked_by_me = FALSE;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1575 HMENUI tmp = malloc(sizeof(struct _hmenui));
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1576 GtkAccelGroup *accel_group;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1577
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1578 if(!tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1579 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1580
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1581 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1582 tmp->menu = gtk_menu_bar_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1583 box = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(location));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1584 gtk_widget_show(tmp->menu);
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1585 accel_group = gtk_accel_group_new();
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1586 gtk_object_set_data(GTK_OBJECT(tmp->menu), "accel", (gpointer)accel_group);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1587
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1588 if(box)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1589 gtk_box_pack_end(GTK_BOX(box), tmp->menu, FALSE, FALSE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1590
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1591 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1592 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1593 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1594
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1595 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1596 * Destroys a menu created with dw_menubar_new or dw_menu_new.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1597 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1598 * menu: Handle of a menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1599 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1600 void dw_menu_destroy(HMENUI *menu)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1601 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1602 if(menu && *menu)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1603 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1604 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1605
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1606 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1607 gtk_widget_destroy((*menu)->menu);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1608 free(*menu);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1609 *menu = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1610 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1611 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1612 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1613
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1614 char _removetilde(char *dest, char *src)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1615 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1616 int z, cur=0;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1617 char accel = '\0';
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1618
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1619 for(z=0;z<strlen(src);z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1620 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1621 if(src[z] != '~')
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1622 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1623 dest[cur] = src[z];
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1624 cur++;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1625 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1626 else
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1627 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1628 dest[cur] = '_';
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1629 accel = src[z+1];
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1630 cur++;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1631 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1632 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1633 dest[cur] = 0;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1634 return accel;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1635 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1636
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1637 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1638 * Adds a menuitem or submenu to an existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1639 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1640 * menu: The handle the the existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1641 * title: The title text on the menu item to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1642 * id: An ID to be used for message passing.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1643 * flags: Extended attributes to set on the menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1644 * end: If TRUE memu is positioned at the end of the menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1645 * check: If TRUE menu is "check"able.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1646 * submenu: Handle to an existing menu to be a submenu or NULL.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1647 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1648 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
1649 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1650 GtkWidget *tmphandle;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1651 char accel, *tempbuf = malloc(strlen(title)+1);
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1652 int _locked_by_me = FALSE, submenucount;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1653 guint tmp_key;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1654 GtkAccelGroup *accel_group;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1655
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1656 if(!menu || !menu->menu)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1657 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1658 free(tempbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1659 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1660 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1661
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1662 DW_MUTEX_LOCK;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1663 accel = _removetilde(tempbuf, title);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1664
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1665 accel_group = (GtkAccelGroup *)gtk_object_get_data(GTK_OBJECT(menu->menu), "accel");
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1666 submenucount = (int)gtk_object_get_data(GTK_OBJECT(menu->menu), "submenucount");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1667
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1668 if(strlen(tempbuf) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1669 tmphandle=gtk_menu_item_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1670 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1671 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1672 if(check)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1673 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1674 char numbuf[10];
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1675 if(accel && accel_group)
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1676 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1677 tmphandle=gtk_check_menu_item_new_with_label("");
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1678 tmp_key = gtk_label_parse_uline(GTK_LABEL(GTK_BIN(tmphandle)->child), tempbuf);
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
1679 gtk_widget_add_accelerator(tmphandle, "activate", accel_group, tmp_key, GDK_MOD1_MASK, 0);
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1680 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1681 else
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1682 tmphandle=gtk_check_menu_item_new_with_label(tempbuf);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1683 gtk_check_menu_item_set_show_toggle(GTK_CHECK_MENU_ITEM(tmphandle), TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1684 sprintf(numbuf, "%lu", id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1685 gtk_object_set_data(GTK_OBJECT(menu->menu), numbuf, (gpointer)tmphandle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1686 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1687 else
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1688 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1689 if(accel && accel_group)
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1690 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1691 tmphandle=gtk_menu_item_new_with_label("");
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1692 tmp_key = gtk_label_parse_uline(GTK_LABEL(GTK_BIN(tmphandle)->child), tempbuf);
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
1693 gtk_widget_add_accelerator(tmphandle, "activate", accel_group, tmp_key, GDK_MOD1_MASK, 0);
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1694 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1695 else
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1696 tmphandle=gtk_menu_item_new_with_label(tempbuf);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1697 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1698 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1699
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1700 gtk_widget_show(tmphandle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1701
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1702 if(submenu)
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1703 {
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1704 char tempbuf[100];
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1705
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1706 sprintf(tempbuf, "submenu%d", submenucount);
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1707 submenucount++;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1708 gtk_menu_item_set_submenu(GTK_MENU_ITEM(tmphandle), submenu->menu);
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1709 gtk_object_set_data(GTK_OBJECT(menu->menu), tempbuf, (gpointer)submenu->menu);
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1710 gtk_object_set_data(GTK_OBJECT(menu->menu), "submenucount", (gpointer)submenucount);
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1711 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1712
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1713 if(GTK_IS_MENU_BAR(menu->menu))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1714 gtk_menu_bar_append(GTK_MENU_BAR(menu->menu), tmphandle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1715 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1716 gtk_menu_append(GTK_MENU(menu->menu), tmphandle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1717
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1718 gtk_object_set_data(GTK_OBJECT(tmphandle), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1719 free(tempbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1720 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1721 return tmphandle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1722 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1723
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1724 GtkWidget *_find_submenu_id(GtkWidget *start, char *name)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1725 {
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1726 GtkWidget *tmp;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1727 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
1728
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1729 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
1730 return tmp;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1731
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1732 for(z=0;z<submenucount;z++)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1733 {
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1734 char tempbuf[100];
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1735 GtkWidget *submenu, *menuitem;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1736
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1737 sprintf(tempbuf, "submenu%d", z);
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1738
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1739 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
1740 {
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1741 if((menuitem = _find_submenu_id(submenu, name)))
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1742 return menuitem;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1743 }
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1744 }
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1745 return NULL;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1746 }
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1747
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1748 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1749 * Sets the state of a menu item check.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1750 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1751 * menu: The handle the the existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1752 * id: Menuitem id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1753 * check: TRUE for checked FALSE for not checked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1754 */
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1755 void dw_menu_item_set_check(HMENUI menu, unsigned long id, int check)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1756 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1757 char numbuf[10];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1758 GtkWidget *tmphandle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1759 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1760
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1761 if(!menu || !menu->menu)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1762 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1763
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1764 DW_MUTEX_LOCK;
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1765 sprintf(numbuf, "%lu", id);
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1766 tmphandle = _find_submenu_id(menu->menu, numbuf);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1767
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1768 if(tmphandle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1769 {
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1770 _dw_ignore_click = 1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1771 if(GTK_CHECK_MENU_ITEM(tmphandle)->active != check)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1772 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
1773 _dw_ignore_click = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1774 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1775 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1776 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1777
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1778 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1779 * Pops up a context menu at given x and y coordinates.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1780 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1781 * menu: The handle the the existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1782 * parent: Handle to the window initiating the popup.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1783 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1784 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1785 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1786 void dw_menu_popup(HMENUI *menu, HWND parent, int x, int y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1787 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1788 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1789
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1790 if(!menu || !*menu)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1791 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1792
93
98cce029a611 Changed handling of menu item click events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 92
diff changeset
1793 popup = parent;
98cce029a611 Changed handling of menu item click events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 92
diff changeset
1794
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1795 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1796 gtk_menu_popup(GTK_MENU((*menu)->menu), NULL, NULL, NULL, NULL, x, y);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1797 free(*menu);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1798 *menu = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1799 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1800 }
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 * Returns the current X and Y coordinates of the mouse pointer.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1805 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1806 * x: Pointer to variable to store X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1807 * y: Pointer to variable to store Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1808 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1809 void dw_pointer_query_pos(long *x, long *y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1810 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1811 GdkModifierType state;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1812 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
1813 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
1814
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
1815 DW_MUTEX_LOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1816 gdk_window_get_pointer (GDK_ROOT_PARENT(), &gx, &gy, &state);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1817 *x = gx;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1818 *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
1819 DW_MUTEX_UNLOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1820 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1821
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1822 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1823 * Sets the X and Y coordinates of the mouse pointer.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1824 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1825 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1826 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1827 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1828 void dw_pointer_set_pos(long x, long y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1829 {
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
1830 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
1831
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
1832 DW_MUTEX_LOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1833 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
1834 DW_MUTEX_UNLOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1835 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1836
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1837 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1838 * Create a container object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1839 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1840 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1841 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1842 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1843 HWND dw_container_new(unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1844 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1845 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1846 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1847
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1848 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1849 tmp = gtk_scrolled_window_new (NULL, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1850 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (tmp),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1851 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1852
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1853 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1854 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1855
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1856 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1857 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1858 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1859
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1860 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1861 * 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
1862 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1863 * 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
1864 * 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
1865 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1866 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
1867 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1868 GtkWidget *tmp, *tree;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1869 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
1870
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1871 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
1872 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
1873 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (tmp),
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1874 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1875
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1876 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
1877 gtk_widget_show(tmp);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1878 tree = gtk_tree_new();
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1879 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
1880 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1881 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
1882 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
1883 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
1884 }
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1885 gtk_tree_set_view_mode(GTK_TREE(tree), GTK_TREE_VIEW_ITEM);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1886 gtk_tree_set_selection_mode(GTK_TREE(tree), GTK_SELECTION_SINGLE);
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1887 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(tmp), tree);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1888 /* 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
1889 gtk_tree_set_selection_mode (GTK_TREE(tree), 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
1890
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1891 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
1892 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
1893
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1894 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
1895 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
1896 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1897
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1898
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1899 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1900 * Create a new static text window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1901 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1902 * text: The text to be display by the static text widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1903 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1904 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1905 HWND dw_text_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1906 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1907 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1908 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1909
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1910 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1911 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
1912
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1913 /* 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
1914 gtk_misc_set_alignment(GTK_MISC(tmp), 0.0f, 0.5f);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1915 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1916 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
1917 gtk_misc_set_alignment(GTK_MISC(tmp), DW_LEFT, DW_LEFT);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1918 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1919 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1920 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1921
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1922 /*
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1923 * 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
1924 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1925 * text: The text to be display by the static text widget.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1926 * id: An ID to be used with WinWindowFromID() or 0L.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1927 */
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1928 HWND dw_status_text_new(char *text, ULONG id)
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1929 {
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1930 GtkWidget *tmp, *frame;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1931 int _locked_by_me = FALSE;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1932
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1933 DW_MUTEX_LOCK;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1934 frame = gtk_frame_new(NULL);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1935 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
1936 tmp = gtk_label_new(text);
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1937 gtk_container_add(GTK_CONTAINER(frame), tmp);
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1938 gtk_widget_show(tmp);
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1939 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
1940
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1941 /* 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
1942 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
1943 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
1944 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
1945 DW_MUTEX_UNLOCK;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1946 return frame;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1947 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1948
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1949 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1950 * Create a new Multiline Editbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1951 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1952 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1953 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1954 HWND dw_mle_new(unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1955 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1956 GtkWidget *tmp, *tmpbox, *scroller;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1957 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1958
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1959 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
1960 #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
1961 tmpbox = gtk_scrolled_window_new (NULL, 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
1962 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (tmpbox),
7d2108cbcd3e Porting DW 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_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
1964 tmp = gtk_text_view_new();
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
1965 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(tmpbox), 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
1966 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(tmp), GTK_WRAP_NONE);
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
1967 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1968 tmpbox = gtk_hbox_new(FALSE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1969 tmp = gtk_text_new(NULL, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1970 gtk_text_set_word_wrap(GTK_TEXT(tmp), FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1971 gtk_text_set_line_wrap(GTK_TEXT(tmp), FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1972 scroller = gtk_vscrollbar_new(GTK_TEXT(tmp)->vadj);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1973 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
1974 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
1975 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
1976 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
1977 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1978 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1979 gtk_object_set_data(GTK_OBJECT(tmpbox), "mle", (gpointer)tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1980 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1981 gtk_widget_show(tmpbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1982 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1983 return tmpbox;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1984 }
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 * Create a new Entryfield window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1988 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1989 * text: The default text to be in the entryfield widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1990 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1991 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1992 HWND dw_entryfield_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1993 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1994 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1995 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1996
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1997 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1998 tmp = gtk_entry_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1999
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2000 gtk_entry_set_text(GTK_ENTRY(tmp), text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2001
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2002 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2003 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2004
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2005 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2006 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2007 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2008
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2009 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2010 * Create a new Entryfield (password) window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2011 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2012 * text: The default text to be in the entryfield widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2013 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2014 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2015 HWND dw_entryfield_password_new(char *text, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2016 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2017 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2018 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2019
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2020 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2021 tmp = gtk_entry_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2022
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2023 gtk_entry_set_visibility(GTK_ENTRY(tmp), FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2024 gtk_entry_set_text(GTK_ENTRY(tmp), text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2025
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2026 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2027 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2028
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2029 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2030 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2031 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2032
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2033 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2034 * Create a new Combobox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2035 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2036 * text: The default text to be in the combpbox widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2037 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2038 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2039 HWND dw_combobox_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2040 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2041 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
2042 SignalHandler *work = malloc(sizeof(SignalHandler));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2043 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2044
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2045 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2046 tmp = gtk_combo_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2047 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(tmp)->entry), text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2048 gtk_combo_set_use_arrows(GTK_COMBO(tmp), TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2049 gtk_object_set_user_data(GTK_OBJECT(tmp), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2050 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2051 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
2052
2d121d4d90c0 Run the _item_select_event() handler on comboboxes even if a handler
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 114
diff changeset
2053 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
2054 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
2055 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
2056
2d121d4d90c0 Run the _item_select_event() handler on comboboxes even if a handler
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 114
diff changeset
2057 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
2058 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2059 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2060 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2061
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2062 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2063 * Create a new button window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2064 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2065 * text: The text to be display by the static text widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2066 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2067 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2068 HWND dw_button_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2069 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2070 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2071 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2072
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2073 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2074 tmp = gtk_button_new_with_label(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2075 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2076 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2077 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2078 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2079 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2080
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2081 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2082 * Create a new bitmap button window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2083 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2084 * text: Bubble help text to be displayed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2085 * id: An ID of a bitmap in the resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2086 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2087 HWND dw_bitmapbutton_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2088 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2089 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2090 GtkWidget *bitmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2091 GtkTooltips *tooltips;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2092 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2093
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2094 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2095 tmp = gtk_button_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2096 bitmap = dw_bitmap_new(id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2097
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2098 if(bitmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2099 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2100 dw_window_set_bitmap(bitmap, id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2101 gtk_container_add (GTK_CONTAINER(tmp), bitmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2102 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2103 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2104 if(text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2105 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2106 tooltips = gtk_tooltips_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2107 gtk_tooltips_set_tip(tooltips, tmp, text, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2108 gtk_object_set_data(GTK_OBJECT(tmp), "tooltip", (gpointer)tooltips);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2109 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2110 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2111 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2112 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2113 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2114
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2115 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2116 * Create a new spinbutton window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2117 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2118 * text: The text to be display by the static text widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2119 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2120 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2121 HWND dw_spinbutton_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2122 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2123 GtkAdjustment *adj;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2124 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2125 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2126
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2127 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2128 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
2129 tmp = gtk_spin_button_new (adj, 0, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2130 gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(tmp), TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2131 gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(tmp), TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2132 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2133 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2134 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2135 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2136 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2137
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2138 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2139 * Create a new radiobutton window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2140 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2141 * text: The text to be display by the static text widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2142 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2143 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2144 HWND dw_radiobutton_new(char *text, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2145 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2146 /* This will have to be fixed in the future. */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2147 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2148 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2149
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2150 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2151 tmp = gtk_radio_button_new_with_label(NULL, text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2152 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2153 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2154
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2155 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2156 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2157 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2158
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2159 /*
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2160 * 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
2161 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2162 * 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
2163 * increments: Number of increments available.
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2164 * id: An ID to be used with WinWindowFromID() or 0L.
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2165 */
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2166 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
2167 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2168 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
2169 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
2170 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
2171
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2172 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
2173 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
2174 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
2175 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
2176 else
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2177 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
2178 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
2179 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
2180 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
2181 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
2182 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
2183 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
2184 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
2185 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
2186 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2187
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2188 /*
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 30
diff changeset
2189 * Create a new percent bar window (widget) to be packed.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2190 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2191 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2192 */
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 30
diff changeset
2193 HWND dw_percent_new(unsigned long id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2194 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2195 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2196 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2197
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2198 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2199 tmp = gtk_progress_bar_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2200 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2201 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2202 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2203 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2204 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2205
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2206 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2207 * Create a new checkbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2208 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2209 * text: The text to be display by the static text widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2210 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2211 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2212 HWND dw_checkbox_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2213 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2214 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2215 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2216
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2217 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2218 tmp = gtk_check_button_new_with_label(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2219 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2220 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2221 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2222 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2223 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2224
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2225 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2226 * Create a new listbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2227 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2228 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2229 * multi: Multiple select TRUE or FALSE.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2230 */
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2231 HWND dw_listbox_new(unsigned long id, int multi)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2232 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2233 GtkWidget *tmp, *list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2234 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2235
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2236 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2237 tmp = gtk_scrolled_window_new(NULL, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2238 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (tmp),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2239 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2240
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2241 list = gtk_list_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2242 gtk_list_set_selection_mode(GTK_LIST(list), multi ? GTK_SELECTION_MULTIPLE : GTK_SELECTION_SINGLE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2243
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2244 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(tmp),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2245 list);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2246 gtk_object_set_user_data(GTK_OBJECT(tmp), list);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2247 gtk_widget_show(list);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2248 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2249 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2250
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2251 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2252 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2253 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2254
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2255 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2256 * Sets the icon used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2257 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2258 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2259 * id: An ID to be used to specify the icon.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2260 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2261 void dw_window_set_icon(HWND handle, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2262 {
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2263 GdkBitmap *bitmap = NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2264 GdkPixmap *icon_pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2265 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2266
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2267 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
2268 icon_pixmap = _find_pixmap(&bitmap, id, handle, NULL, NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2269
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2270 if(handle->window && icon_pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2271 gdk_window_set_icon(handle->window, NULL, icon_pixmap, bitmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2272
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2273 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2274 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2275
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2276 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2277 * Sets the bitmap used for a given static window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2278 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2279 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2280 * id: An ID to be used to specify the icon.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2281 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2282 void dw_window_set_bitmap(HWND handle, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2283 {
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2284 GdkBitmap *bitmap = NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2285 GdkPixmap *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2286 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2287
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2288 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
2289 tmp = _find_pixmap(&bitmap, id, handle, NULL, NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2290 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
2291 #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
2292 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
2293 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2294 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
2295 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2296 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2297 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2298
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2299 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2300 * Sets the text used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2301 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2302 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2303 * text: The text associsated with a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2304 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2305 void dw_window_set_text(HWND handle, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2306 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2307 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2308
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2309 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2310 if(GTK_IS_ENTRY(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2311 gtk_entry_set_text(GTK_ENTRY(handle), text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2312 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2313 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(handle)->entry), text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2314 else if(GTK_IS_LABEL(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2315 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
2316 else if(GTK_IS_FRAME(handle))
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2317 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2318 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
2319 if(tmp && GTK_IS_LABEL(tmp))
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2320 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
2321 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2322 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2323 }
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 * Gets the text used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2327 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2328 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2329 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2330 * text: The text associsated with a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2331 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2332 char *dw_window_get_text(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2333 {
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2334 #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
2335 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
2336 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2337 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
2338 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2339 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2340
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2341 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2342 if(GTK_IS_ENTRY(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2343 possible = gtk_entry_get_text(GTK_ENTRY(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2344 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2345 possible = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(handle)->entry));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2346
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2347 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2348 return strdup(possible);
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 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2352 * Disables given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2353 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2354 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2355 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2356 void dw_window_disable(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2357 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2358 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2359
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2360 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2361 gtk_widget_set_sensitive(handle, FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2362 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2363 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2364
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2365 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2366 * Enables given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2367 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2368 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2369 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2370 void dw_window_enable(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2371 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2372 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2373
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2374 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2375 gtk_widget_set_sensitive(handle, TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2376 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2377 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2378
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2379 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
2380 {
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2381 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
2382
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2383 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
2384 {
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2385 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
2386 {
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2387 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
2388 x++;
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2389 }
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2390 }
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2391 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
2392 }
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2393
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2394 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2395 * Adds text to an MLE box and returns the current point.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2396 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2397 * handle: Handle to the MLE to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2398 * buffer: Text buffer to be imported.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2399 * startpoint: Point to start entering text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2400 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2401 unsigned int dw_mle_import(HWND handle, char *buffer, int startpoint)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2402 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2403 unsigned int tmppoint = startpoint;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2404 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2405
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2406 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
2407 #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
2408 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
2409 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2410 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
2411 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2412 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2413 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2414 GdkFont *font = (GdkFont *)gtk_object_get_data(GTK_OBJECT(handle), "gdkfont");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2415
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2416 #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
2417 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
2418 {
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2419 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
2420 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
2421 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
2422
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2423 _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
2424
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2425 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
2426 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
2427 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
2428 gtk_text_buffer_insert_at_cursor(tbuffer, impbuf, -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
2429 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
2430 }
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2431 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2432 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2433 {
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2434 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
2435 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
2436 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
2437
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2438 _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
2439
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2440 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
2441 gtk_text_insert(GTK_TEXT(tmp), font, fore, back, impbuf, -1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2442 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
2443 free(impbuf);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2444 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2445 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2446 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2447 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2448 return tmppoint;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2449 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2450
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2451 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2452 * Grabs text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2453 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2454 * handle: Handle to the MLE to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2455 * buffer: Text buffer to be exported.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2456 * startpoint: Point to start grabbing text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2457 * length: Amount of text to be grabbed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2458 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2459 void dw_mle_export(HWND handle, char *buffer, int startpoint, int length)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2460 {
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2461 #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
2462 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2463 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2464 gchar *text;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2465
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2466 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2467 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2468 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2469 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2470
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2471 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2472 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2473 text = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), startpoint, startpoint + length);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2474 if(text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2475 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2476 strcpy(buffer, text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2477 g_free(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2478 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2479 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2480 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2481 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
2482 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2483 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2484
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2485 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2486 * Obtains information about an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2487 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2488 * handle: Handle to the MLE to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2489 * bytes: A pointer to a variable to return the total bytes.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2490 * lines: A pointer to a variable to return the number of lines.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2491 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2492 void dw_mle_query(HWND handle, unsigned long *bytes, unsigned long *lines)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2493 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2494 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2495
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2496 if(bytes)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2497 *bytes = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2498 if(lines)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2499 *lines = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2500
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2501 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
2502 #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
2503 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
2504 {
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2505 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2506
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2507 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
2508 {
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2509 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
2510
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2511 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
2512 *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
2513 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
2514 *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
2515 }
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2516 }
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2517 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2518 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2519 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2520 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2521
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2522 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2523 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2524 if(bytes)
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2525 *bytes = gtk_text_get_length(GTK_TEXT(tmp)) + 1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2526 if(lines)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2527 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2528 gchar *text;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2529
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2530 *lines = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2531 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
2532
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2533 if(text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2534 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2535 int z, len = strlen(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2536
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2537 for(z=0;z<len;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2538 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2539 if(text[z] == '\n')
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2540 (*lines)++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2541 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2542 g_free(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2543 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2544 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2545 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2546 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2547 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2548 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2549 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2550
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2551 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2552 * Deletes text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2553 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2554 * handle: Handle to the MLE to be deleted from.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2555 * startpoint: Point to start deleting text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2556 * length: Amount of text to be deleted.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2557 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2558 void dw_mle_delete(HWND handle, int startpoint, int length)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2559 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2560 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2561
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2562 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
2563 #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
2564 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2565 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2566 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2567 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2568
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2569 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2570 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2571 gtk_text_set_point(GTK_TEXT(tmp), startpoint);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2572 gtk_text_forward_delete(GTK_TEXT(tmp), length);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2573 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2574 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2575 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2576 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2577 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2578
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2579 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2580 * Clears all text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2581 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2582 * handle: Handle to the MLE to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2583 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2584 void dw_mle_clear(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2585 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2586 int length, _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2587
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2588 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
2589 #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
2590 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2591 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2592 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2593 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2594
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2595 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2596 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2597 length = gtk_text_get_length(GTK_TEXT(tmp));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2598 gtk_text_set_point(GTK_TEXT(tmp), 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2599 gtk_text_forward_delete(GTK_TEXT(tmp), length);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2600 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2601 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2602 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2603 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2604 }
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 * Sets the visible line of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2608 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2609 * handle: Handle to the MLE.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2610 * line: Line to be visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2611 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2612 void dw_mle_set_visible(HWND handle, int line)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2613 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2614 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2615
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2616 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
2617 #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
2618 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2619 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2620 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2621 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2622
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2623 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2624 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2625 unsigned long lines;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2626 float pos, ratio;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2627
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2628 dw_mle_query(handle, NULL, &lines);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2629
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2630 if(lines)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2631 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2632 ratio = (float)line/(float)lines;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2633
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2634 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
2635
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2636 gtk_adjustment_set_value(GTK_TEXT(tmp)->vadj, pos);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2637 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2638 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2639 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2640 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2641 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2642 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2643
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2644 /*
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2645 * Sets the editablity of an MLE box.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2646 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2647 * handle: Handle to the MLE.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2648 * 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
2649 */
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2650 void dw_mle_set_editable(HWND handle, int state)
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2651 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2652 int _locked_by_me = FALSE;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2653
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2654 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
2655 #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
2656 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
2657 {
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2658 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2659
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2660 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
2661 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
2662 }
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2663 #else
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2664 if(GTK_IS_BOX(handle))
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2665 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2666 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2667
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2668 if(tmp && GTK_IS_TEXT(tmp))
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2669 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
2670 }
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2671 #endif
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2672 DW_MUTEX_UNLOCK;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2673 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2674
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2675 /*
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2676 * Sets the word wrap state of an MLE box.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2677 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2678 * handle: Handle to the MLE.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2679 * 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
2680 */
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2681 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
2682 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2683 int _locked_by_me = FALSE;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2684
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2685 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
2686 #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
2687 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
2688 {
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2689 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2690
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2691 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
2692 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
2693 }
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2694 #else
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2695 if(GTK_IS_BOX(handle))
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2696 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2697 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2698
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2699 if(tmp && GTK_IS_TEXT(tmp))
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2700 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2701 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
2702 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
2703 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2704 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2705 #endif
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2706 DW_MUTEX_UNLOCK;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2707 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2708
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2709 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2710 * Sets the current cursor position of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2711 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2712 * handle: Handle to the MLE to be positioned.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2713 * point: Point to position cursor.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2714 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2715 void dw_mle_set(HWND handle, int point)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2716 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2717 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2718
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2719 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
2720 #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
2721 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2722 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2723 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2724 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2725
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2726 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2727 {
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2728 unsigned long chars;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2729 float pos, ratio;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2730
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2731 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
2732
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2733 if(chars)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2734 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2735 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
2736
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2737 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
2738
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2739 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
2740 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2741 gtk_text_set_point(GTK_TEXT(tmp), point);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2742 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2743 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2744 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2745 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2746 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2747
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2748 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2749 * Finds text in an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2750 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2751 * handle: Handle to the MLE to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2752 * text: Text to search for.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2753 * point: Start point of search.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2754 * flags: Search specific flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2755 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2756 int dw_mle_search(HWND handle, char *text, int point, unsigned long flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2757 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2758 int _locked_by_me = FALSE, retval = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2759
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2760 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
2761 #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
2762 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2763 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2764 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2765 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2766
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2767 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2768 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2769 int len = gtk_text_get_length(GTK_TEXT(tmp));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2770 gchar *tmpbuf;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2771
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2772 tmpbuf = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), 0, len);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2773 if(tmpbuf)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2774 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2775 int z, textlen;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2776
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2777 textlen = strlen(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2778
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2779 if(flags & DW_MLE_CASESENSITIVE)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2780 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2781 for(z=point;z<(len-textlen) && !retval;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2782 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2783 if(strncmp(&tmpbuf[z], text, textlen) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2784 retval = z + textlen;
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 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2788 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2789 for(z=point;z<(len-textlen) && !retval;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2790 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2791 if(strncasecmp(&tmpbuf[z], text, textlen) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2792 retval = z + textlen;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2793 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2794 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2795
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2796 if(retval)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2797 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2798 gtk_text_set_point(GTK_TEXT(tmp), retval - textlen);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2799 gtk_editable_select_region(&(GTK_TEXT(tmp)->editable), retval - textlen, retval);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2800 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2801
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2802 g_free(tmpbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2803 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2804 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2805 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2806 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2807 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2808 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2809 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2810
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2811 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2812 * Stops redrawing of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2813 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2814 * handle: Handle to the MLE to freeze.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2815 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2816 void dw_mle_freeze(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2817 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2818 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2819
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2820 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
2821 #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
2822 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2823 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2824 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2825 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2826
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2827 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2828 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2829 gtk_text_freeze(GTK_TEXT(tmp));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2830 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2831 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2832 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2833 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2834 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2835
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2836 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2837 * Resumes redrawing of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2838 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2839 * handle: Handle to the MLE to thaw.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2840 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2841 void dw_mle_thaw(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2842 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2843 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2844
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2845 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
2846 #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
2847 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2848 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2849 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2850 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2851
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2852 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2853 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2854 gtk_text_thaw(GTK_TEXT(tmp));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2855 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2856 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2857 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2858 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2859 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2860
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2861 /*
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 30
diff changeset
2862 * Returns the range of the percent bar.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2863 * 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
2864 * handle: Handle to the percent bar to be queried.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2865 */
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 30
diff changeset
2866 unsigned int dw_percent_query_range(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2867 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2868 return 100;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2869 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2870
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2871 /*
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 30
diff changeset
2872 * Sets the percent bar position.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2873 * 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
2874 * 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
2875 * position: Position of the percent bar withing the range.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2876 */
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 30
diff changeset
2877 void dw_percent_set_pos(HWND handle, unsigned int position)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2878 {
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;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2882 gtk_progress_bar_update(GTK_PROGRESS_BAR(handle), (gfloat)position/100);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2883 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2884 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2885
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2886 /*
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2887 * 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
2888 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2889 * 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
2890 */
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2891 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
2892 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2893 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
2894 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
2895
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2896 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
2897 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
2898
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2899 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
2900 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
2901 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
2902 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2903 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
2904 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
2905
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2906 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
2907 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
2908 else
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2909 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
2910 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2911 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
2912 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
2913 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2914
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2915 /*
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2916 * 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
2917 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2918 * 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
2919 * 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
2920 */
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2921 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
2922 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2923 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
2924 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
2925
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2926 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
2927 return;
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2928
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2929 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
2930 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
2931 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
2932 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2933 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
2934
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2935 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
2936 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
2937 else
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2938 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
2939 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2940 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
2941 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2942
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2943 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2944 * Sets the spinbutton value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2945 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2946 * handle: Handle to the spinbutton to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2947 * position: Current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2948 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2949 void dw_spinbutton_set_pos(HWND handle, long position)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2950 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2951 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2952
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2953 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2954 gtk_spin_button_set_value(GTK_SPIN_BUTTON(handle), (gfloat)position);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2955 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2956 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2957
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2958 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2959 * Sets the spinbutton limits.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2960 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2961 * handle: Handle to the spinbutton to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2962 * position: Current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2963 * position: Current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2964 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2965 void dw_spinbutton_set_limits(HWND handle, long upper, long lower)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2966 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2967 long curval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2968 GtkAdjustment *adj;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2969 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2970
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2971 curval = dw_spinbutton_query(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2972 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2973 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
2974 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2975 }
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 * Sets the entryfield character limit.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2979 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2980 * handle: Handle to the spinbutton to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2981 * limit: Number of characters the entryfield will take.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2982 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2983 void dw_entryfield_set_limit(HWND handle, ULONG limit)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2984 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2985 /* TODO: can this be done after the fact? */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2986 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2987
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2988 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2989 * Returns the current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2990 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2991 * handle: Handle to the spinbutton to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2992 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2993 long dw_spinbutton_query(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2994 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2995 long retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2996 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2997
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2998 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2999 retval = (long)gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3000 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3001
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3002 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3003 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3004
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3005 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3006 * Returns the state of the checkbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3007 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3008 * handle: Handle to the checkbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3009 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3010 int dw_checkbox_query(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3011 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3012 int retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3013 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3014
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3015 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3016 retval = GTK_TOGGLE_BUTTON(handle)->active;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3017 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3018
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3019 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3020 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3021
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3022 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3023 * Sets the state of the checkbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3024 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3025 * handle: Handle to the checkbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3026 * value: TRUE for checked, FALSE for unchecked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3027 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3028 void dw_checkbox_set(HWND handle, int value)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3029 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3030 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3031
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3032 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3033 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(handle), value);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3034 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3035 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3036
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3037 /*
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3038 * 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
3039 * Parameters:
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3040 * 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
3041 * 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
3042 * title: The text title of the entry.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3043 * icon: Handle to coresponding icon.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3044 * parent: Parent handle or 0 if root.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3045 * itemdata: Item specific data.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3046 */
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3047 HWND dw_tree_insert_after(HWND handle, HWND item, char *title, unsigned long icon, HWND parent, void *itemdata)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3048 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3049 GtkWidget *newitem, *tree, *subtree, *label, *hbox, *pixmap;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3050 GdkPixmap *gdkpix;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3051 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
3052 int position = -1;
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3053 int _locked_by_me = FALSE;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3054
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3055 if(!handle)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3056 return NULL;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3057
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3058 DW_MUTEX_LOCK;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3059 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
3060 if(!tree || !GTK_IS_TREE(tree))
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3061 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3062 DW_MUTEX_UNLOCK;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3063 return NULL;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3064 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3065
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3066 if(item && GTK_IS_TREE_ITEM(item))
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3067 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
3068
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3069 position++;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3070
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3071 newitem = gtk_tree_item_new();
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3072 label = gtk_label_new(title);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3073 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
3074 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
3075 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
3076 hbox = gtk_hbox_new(FALSE, 2);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3077 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
3078 gdkpix = _find_pixmap(&gdkbmp, icon, hbox, NULL, 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
3079 #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
3080 pixmap = gtk_image_new_from_pixmap(gdkpix, gdkbmp);
120
7d2108cbcd3e Porting DW 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 #else
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3082 pixmap = gtk_pixmap_new(gdkpix, gdkbmp);
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3083 #endif
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3084 gtk_container_add(GTK_CONTAINER(newitem), hbox);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3085 gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, TRUE, 0);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3086 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
3087 gtk_widget_show(label);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3088 gtk_widget_show(pixmap);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3089 gtk_widget_show(hbox);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3090
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3091 if(parent)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3092 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3093 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
3094 if(!subtree)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3095 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3096 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
3097 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
3098
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3099 subtree = gtk_tree_new();
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3100
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3101 if(thisfunc && work)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3102 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
3103
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3104 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
3105 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
3106
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3107 if(thisfunc && work)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3108 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
3109
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3110 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
3111 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
3112 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
3113 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
3114 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
3115 gtk_widget_show(subtree);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3116 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
3117 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
3118 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3119 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
3120 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
3121 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3122 else
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3123 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3124 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
3125 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
3126 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3127 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
3128 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
3129 gtk_widget_show(newitem);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3130 DW_MUTEX_UNLOCK;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3131 return newitem;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3132 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3133
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3134 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3135 * 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
3136 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3137 * 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
3138 * 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
3139 * 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
3140 * 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
3141 * 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
3142 */
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
3143 HWND dw_tree_insert(HWND handle, char *title, unsigned long icon, HWND 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
3144 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3145 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
3146 GdkPixmap *gdkpix;
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3147 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
3148 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
3149
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3150 if(!handle)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3151 return NULL;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3152
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3153 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
3154 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
3155 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
3156 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3157 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
3158 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
3159 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3160 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
3161 label = gtk_label_new(title);
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3162 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
3163 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
3164 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
3165 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
3166 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
3167 gdkpix = _find_pixmap(&gdkbmp, icon, hbox, NULL, 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
3168 #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
3169 pixmap = gtk_image_new_from_pixmap(gdkpix, gdkbmp);
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3170 #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
3171 pixmap = gtk_pixmap_new(gdkpix, gdkbmp);
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3172 #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
3173 gtk_container_add(GTK_CONTAINER(item), hbox);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3174 gtk_box_pack_start(GTK_BOX(hbox), pixmap, 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
3175 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
3176 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
3177 gtk_widget_show(pixmap);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3178 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
3179
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3180 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
3181 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3182 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
3183 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
3184 {
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3185 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
3186 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
3187
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3188 subtree = gtk_tree_new();
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3189
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3190 if(thisfunc && work)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3191 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
3192
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
3193 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
3194 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
3195
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3196 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
3197 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
3198
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3199 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
3200 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
3201 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
3202 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
3203 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
3204 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
3205 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
3206 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
3207 }
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3208 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
3209 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
3210 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3211 else
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3212 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3213 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
3214 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
3215 }
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
3216 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
3217 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
3218 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
3219 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
3220 return item;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3221 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3222
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3223 /*
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
3224 * 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
3225 * 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
3226 * 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
3227 * 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
3228 * 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
3229 * 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
3230 */
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3231 void dw_tree_set(HWND handle, HWND item, char *title, unsigned long 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
3232 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3233 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
3234 GdkPixmap *gdkpix;
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3235 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
3236 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
3237 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
3238
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3239 if(!handle || !item)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3240 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3241
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
3242 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
3243 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
3244 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
3245 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
3246 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
3247 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
3248 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
3249 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
3250 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
3251 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
3252 gdkpix = _find_pixmap(&gdkbmp, icon, hbox, NULL, 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
3253 #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
3254 pixmap = gtk_image_new_from_pixmap(gdkpix, gdkbmp);
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3255 #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
3256 pixmap = gtk_pixmap_new(gdkpix, gdkbmp);
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3257 #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
3258 gtk_container_add(GTK_CONTAINER(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
3259 gtk_box_pack_start(GTK_BOX(hbox), pixmap, 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
3260 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
3261 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
3262 gtk_widget_show(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
3263 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
3264 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
3265 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3266
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3267 /*
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3268 * 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
3269 * 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
3270 * 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
3271 * 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
3272 * 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
3273 */
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3274 void dw_tree_set_data(HWND handle, HWND item, void *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
3275 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3276 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
3277
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3278 if(!handle || !item)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3279 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3280
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
3281 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
3282 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
3283 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
3284 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3285
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3286 /*
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3287 * 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
3288 * 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
3289 * 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
3290 * 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
3291 */
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3292 void dw_tree_item_select(HWND handle, HWND 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
3293 {
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
3294 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
3295 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
3296
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3297 if(!handle || !item)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3298 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3299
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
3300 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
3301 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
3302 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
3303 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
3304 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
3305 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
3306 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
3307 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
3308 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3309
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3310 /*
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3311 * Removes all nodes from a tree.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3312 * Parameters:
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3313 * 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
3314 */
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3315 void dw_tree_clear(HWND handle)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3316 {
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3317 GtkWidget *tree;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3318 int _locked_by_me = FALSE;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3319
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3320 if(!handle)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3321 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3322
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3323 DW_MUTEX_LOCK;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3324 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
3325 if(!tree || !GTK_IS_TREE(tree))
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3326 {
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3327 DW_MUTEX_UNLOCK;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3328 return;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3329 }
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
3330 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
3331 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
3332 DW_MUTEX_UNLOCK;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3333 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3334
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3335 /*
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
3336 * 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
3337 * 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
3338 * 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
3339 * 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
3340 */
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3341 void dw_tree_expand(HWND handle, HWND 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
3342 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3343 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
3344
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3345 if(!handle || !item)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3346 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3347
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
3348 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
3349 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
3350 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
3351 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
3352 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3353
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3354 /*
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3355 * 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
3356 * 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
3357 * 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
3358 * 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
3359 */
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3360 void dw_tree_collapse(HWND handle, HWND 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
3361 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3362 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
3363
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3364 if(!handle || !item)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3365 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3366
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
3367 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
3368 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
3369 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
3370 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
3371 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3372
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3373 /*
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3374 * Removes a node from a tree.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3375 * Parameters:
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3376 * 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
3377 * item: Handle to node to be deleted.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3378 */
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3379 void dw_tree_delete(HWND handle, HWND item)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3380 {
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3381 GtkWidget *tree, *lastselect, *parenttree;
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3382 int _locked_by_me = FALSE;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3383
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3384 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
3385 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3386
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3387 DW_MUTEX_LOCK;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3388 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
3389 if(!tree || !GTK_IS_TREE(tree))
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3390 {
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3391 DW_MUTEX_UNLOCK;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3392 return;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3393 }
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
3394
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
3395 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
3396
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
3397 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
3398
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
3399 if(lastselect == item)
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3400 {
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
3401 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
3402 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
3403 }
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3404
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3405 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
3406 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
3407 DW_MUTEX_UNLOCK;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3408 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3409
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3410 int _dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator, int extra)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3411 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3412 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3413 char numbuf[10];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3414 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3415 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3416
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3417 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3418 clist = gtk_clist_new_with_titles(count, (gchar **)titles);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3419 if(!clist)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3420 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3421 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3422 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3423 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3424
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3425 gtk_signal_connect(GTK_OBJECT(clist), "select_row", GTK_SIGNAL_FUNC(_select_row), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3426 gtk_signal_connect(GTK_OBJECT(clist), "unselect_row", GTK_SIGNAL_FUNC(_unselect_row), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3427
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3428 gtk_clist_set_column_auto_resize(GTK_CLIST(clist), 0, TRUE);
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
3429 gtk_clist_set_selection_mode(GTK_CLIST(clist), GTK_SELECTION_SINGLE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3430 gtk_container_add(GTK_CONTAINER(handle), clist);
72
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
3431 gtk_object_set_data(GTK_OBJECT(clist), "multi", (gpointer)0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3432 gtk_object_set_user_data(GTK_OBJECT(handle), (gpointer)clist);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3433 gtk_widget_show(clist);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3434 gtk_object_set_data(GTK_OBJECT(clist), "colcount", (gpointer)count);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3435
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3436 if(extra)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3437 gtk_clist_set_column_width(GTK_CLIST(clist), 1, 120);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3438
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3439 for(z=0;z<count;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3440 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3441 if(!extra || z > 1)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3442 gtk_clist_set_column_width(GTK_CLIST(clist), z, 50);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3443 sprintf(numbuf, "%d", z);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3444 gtk_object_set_data(GTK_OBJECT(clist), numbuf, (gpointer)flags[z]);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3445 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3446
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3447 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3448 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3449 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3450
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3451 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3452 * Sets up the container columns.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3453 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3454 * handle: Handle to the container to be configured.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3455 * flags: An array of unsigned longs with column flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3456 * titles: An array of strings with column text titles.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3457 * count: The number of columns (this should match the arrays).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3458 * separator: The column number that contains the main separator.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3459 * (this item may only be used in OS/2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3460 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3461 int dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3462 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3463 return _dw_container_setup(handle, flags, titles, count, separator, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3464 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3465
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3466 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3467 * Sets up the filesystem columns, note: filesystem always has an icon/filename field.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3468 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3469 * handle: Handle to the container to be configured.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3470 * flags: An array of unsigned longs with column flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3471 * titles: An array of strings with column text titles.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3472 * count: The number of columns (this should match the arrays).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3473 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3474 int dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3475 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3476 char **newtitles = malloc(sizeof(char *) * (count + 2));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3477 unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 2));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3478
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3479 newtitles[0] = "Icon";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3480 newtitles[1] = "Filename";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3481
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3482 newflags[0] = DW_CFA_BITMAPORICON | DW_CFA_CENTER | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3483 newflags[1] = DW_CFA_STRING | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3484
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3485 memcpy(&newtitles[2], titles, sizeof(char *) * count);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3486 memcpy(&newflags[2], flags, sizeof(unsigned long) * count);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3487
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3488 _dw_container_setup(handle, newflags, newtitles, count + 2, 2, 1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3489
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3490 free(newtitles);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3491 free(newflags);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3492 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3493 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3494
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3495 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3496 * Obtains an icon from a module (or header in GTK).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3497 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3498 * module: Handle to module (DLL) in OS/2 and Windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3499 * id: A unsigned long id int the resources on OS/2 and
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3500 * Windows, on GTK this is converted to a pointer
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3501 * to an embedded XPM.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3502 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3503 unsigned long dw_icon_load(unsigned long module, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3504 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3505 return id;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3506 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3507
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3508 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3509 * Frees a loaded resource in OS/2 and Windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3510 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3511 * handle: Handle to icon returned by dw_icon_load().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3512 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3513 void dw_icon_free(unsigned long handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3514 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3515 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3516
72
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
3517 /* 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
3518 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
3519 {
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
3520 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
3521
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
3522 if(list)
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
3523 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
3524
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
3525 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
3526
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 72
diff changeset
3527 _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
3528 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
3529 _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
3530 }
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
3531
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3532 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3533 * Allocates memory used to populate a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3534 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3535 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3536 * rowcount: The number of items to be populated.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3537 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3538 void *dw_container_alloc(HWND handle, int rowcount)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3539 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3540 int z, count = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3541 GtkWidget *clist;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3542 GdkColor *fore, *back;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3543 char **blah;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3544 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3545
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3546 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3547 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3548 if(!clist)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3549 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3550 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3551 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3552 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3553
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3554 count = (int)gtk_object_get_data(GTK_OBJECT(clist), "colcount");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3555
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3556 if(!count)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3557 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3558 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3559 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3560 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3561
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3562 blah = malloc(sizeof(char *) * count);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3563 memset(blah, 0, sizeof(char *) * count);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3564
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3565 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
3566 back = (GdkColor *)gtk_object_get_data(GTK_OBJECT(clist), "backgdk");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3567 gtk_clist_freeze(GTK_CLIST(clist));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3568 for(z=0;z<rowcount;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3569 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3570 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
3571 if(fore)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3572 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
3573 if(back)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3574 gtk_clist_set_background(GTK_CLIST(clist), z, back);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3575 }
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3576 gtk_object_set_data(GTK_OBJECT(clist), "rowcount", (gpointer)rowcount);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3577 free(blah);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3578 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3579 return (void *)handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3580 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3581
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3582 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3583 * Sets an item in specified row and column to the given data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3584 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3585 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3586 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3587 * column: Zero based column of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3588 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3589 * data: Pointer to the data to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3590 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3591 void dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3592 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3593 char numbuf[10], textbuffer[100];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3594 int flag = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3595 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3596 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3597
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3598 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3599 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3600 if(!clist)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3601 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3602 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3603 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3604 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3605
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3606 sprintf(numbuf, "%d", column);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3607 flag = (int)gtk_object_get_data(GTK_OBJECT(clist), numbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3608
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3609 if(flag & DW_CFA_BITMAPORICON)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3610 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3611 long hicon = *((long *)data);
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3612 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
3613 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
3614
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3615 if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3616 gtk_clist_set_pixmap(GTK_CLIST(clist), row, column, pixmap, bitmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3617 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3618 else if(flag & DW_CFA_STRING)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3619 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3620 char *tmp = *((char **)data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3621 gtk_clist_set_text(GTK_CLIST(clist), row, column, tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3622 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3623 else if(flag & DW_CFA_ULONG)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3624 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3625 ULONG tmp = *((ULONG *)data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3626
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3627 sprintf(textbuffer, "%lu", tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3628
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3629 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3630 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3631 else if(flag & DW_CFA_DATE)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3632 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3633 CDATE fdate = *((CDATE *)data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3634
92
0a085f295e81 A couple more minor changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 91
diff changeset
3635 if(/*fdate.month > -1 &&*/ fdate.month < 12 && fdate.day > 0 && fdate.year > 0)
87
1eb72c0e8c79 Fixed a problem with the date type in the containers... month should be
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 86
diff changeset
3636 sprintf(textbuffer, "%s %d, %d", monthlist[fdate.month], fdate.day, fdate.year);
46
30d091bc7899 Fixed an error in the container date code on Windows and Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 41
diff changeset
3637 else
30d091bc7899 Fixed an error in the container date code on Windows and Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 41
diff changeset
3638 strcpy(textbuffer, "");
30d091bc7899 Fixed an error in the container date code on Windows and Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 41
diff changeset
3639
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3640 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3641 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3642 else if(flag & DW_CFA_TIME)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3643 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3644 CTIME ftime = *((CTIME *)data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3645
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3646 if(ftime.hours > 12)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3647 sprintf(textbuffer, "%d:%s%dpm", ftime.hours - 12, (ftime.minutes < 10) ? "0" : "", ftime.minutes);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3648 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3649 sprintf(textbuffer, "%d:%s%dam", ftime.hours ? ftime.hours : 12, (ftime.minutes < 10) ? "0" : "", ftime.minutes);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3650 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3651 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3652 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3653 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3654
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3655 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3656 * Sets an item in specified row and column to the given data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3657 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3658 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3659 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3660 * column: Zero based column of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3661 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3662 * data: Pointer to the data to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3663 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3664 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
3665 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3666 dw_container_set_item(handle, pointer, 0, row, (void *)&icon);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3667 dw_container_set_item(handle, pointer, 1, row, (void *)&filename);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3668 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3669
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3670 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3671 * Sets an item in specified row and column to the given data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3672 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3673 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3674 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3675 * column: Zero based column of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3676 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3677 * data: Pointer to the data to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3678 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3679 void dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3680 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3681 dw_container_set_item(handle, pointer, column + 2, row, data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3682 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3683
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3684 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3685 * 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
3686 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3687 * 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
3688 * 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
3689 * 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
3690 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3691 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
3692 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3693 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
3694 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
3695
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3696 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
3697 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
3698
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3699 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
3700 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
3701 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
3702 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3703
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3704 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3705 * Sets the title of a row in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3706 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3707 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3708 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3709 * title: String title of the item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3710 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3711 void dw_container_set_row_title(void *pointer, int row, char *title)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3712 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3713 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3714 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3715
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3716 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3717 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(pointer));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3718
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3719 if(clist)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3720 gtk_clist_set_row_data(GTK_CLIST(clist), row, (gpointer)title);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3721 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3722 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3723
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3724 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3725 * Sets the title of a row in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3726 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3727 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3728 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3729 * rowcount: The number of rows to be inserted.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3730 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3731 void dw_container_insert(HWND handle, void *pointer, int rowcount)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3732 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3733 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3734 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3735
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3736 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3737 clist = gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3738
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3739 if(clist && GTK_IS_CLIST(clist))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3740 gtk_clist_thaw(GTK_CLIST(clist));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3741 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3742 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3743
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3744 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3745 * 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
3746 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3747 * 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
3748 * 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
3749 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3750 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
3751 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3752 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
3753 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
3754
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3755 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
3756 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
3757 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
3758 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3759 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
3760
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3761 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
3762
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
3763 _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
3764
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3765 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
3766 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
3767
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3768 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
3769 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
3770 else
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3771 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
3772
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3773 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
3774 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3775 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
3776 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3777
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3778 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3779 * Removes all rows from a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3780 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3781 * 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
3782 * redraw: TRUE to cause the container to redraw immediately.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3783 */
52
0804483f6320 Added a redraw parameter to dw_container_clear().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 51
diff changeset
3784 void dw_container_clear(HWND handle, int redraw)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3785 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3786 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3787 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3788
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3789 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3790 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3791 if(clist && GTK_IS_CLIST(clist))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3792 {
72
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
3793 _dw_unselect(clist);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3794 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
3795 gtk_object_set_data(GTK_OBJECT(clist), "rowcount", (gpointer)0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3796 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3797 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3798 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3799
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3800 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3801 * Removes all rows from a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3802 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3803 * handle: Handle to the window (widget) to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3804 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3805 void dw_container_set_view(HWND handle, unsigned long flags, int iconwidth, int iconheight)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3806 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3807 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3808
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3809 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3810 * 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
3811 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3812 * 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
3813 * 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
3814 * 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
3815 * 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
3816 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3817 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
3818 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3819 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
3820 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
3821 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
3822
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3823 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
3824 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
3825 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
3826 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3827 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
3828 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
3829 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3830 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
3831 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3832 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
3833 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
3834 break;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3835 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
3836 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
3837 break;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3838 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3839 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
3840 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3841 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3842 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
3843 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3844
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3845 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3846 * Starts a new query of a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3847 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3848 * handle: Handle to the window (widget) to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3849 * flags: If this parameter is DW_CRA_SELECTED it will only
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3850 * return items that are currently selected. Otherwise
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3851 * it will return all records in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3852 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3853 char *dw_container_query_start(HWND handle, unsigned long flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3854 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3855 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3856 GList *list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3857 char *retval = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3858 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3859
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3860 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3861 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3862
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3863 if(!clist)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3864 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3865 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3866 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3867 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3868
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3869 /* 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
3870 if(flags & DW_CRA_SELECTED || flags & DW_CRA_CURSORED)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3871 {
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3872 /* 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
3873 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
3874 if(list)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3875 g_list_free(list);
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3876
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3877 /* 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
3878 * current selection list.
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3879 */
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3880 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
3881 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
3882 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
3883 _dw_unselect(clist);
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3884
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3885 if(list)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3886 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3887 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
3888 if(list->data)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3889 retval = list->data;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3890 else
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3891 retval = "";
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3892 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3893 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3894 else
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3895 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3896 retval = (char *)gtk_clist_get_row_data(GTK_CLIST(clist), 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3897 gtk_object_set_data(GTK_OBJECT(clist), "querypos", (gpointer)1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3898 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3899 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3900 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3901 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3902
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3903 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3904 * Continues an existing query of a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3905 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3906 * handle: Handle to the window (widget) to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3907 * flags: If this parameter is DW_CRA_SELECTED it will only
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3908 * return items that are currently selected. Otherwise
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3909 * it will return all records in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3910 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3911 char *dw_container_query_next(HWND handle, unsigned long flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3912 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3913 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3914 GList *list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3915 char *retval = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3916 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3917
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3918 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3919 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3920
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3921 if(!clist)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3922 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3923 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3924 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3925 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3926
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3927 /* 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
3928 if(flags & DW_CRA_SELECTED || flags & DW_CRA_CURSORED)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3929 {
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3930 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
3931
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3932 if(list)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3933 {
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3934 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
3935 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
3936
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3937 while(list && counter < pos)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3938 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3939 list = list->next;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3940 counter++;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3941 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3942
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3943 if(list && list->data)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3944 retval = list->data;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3945 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
3946 retval = "";
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3947 }
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3948 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3949 else
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3950 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3951 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
3952
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3953 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
3954 gtk_object_set_data(GTK_OBJECT(clist), "querypos", (gpointer)pos+1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3955 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3956 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3957 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3958 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3959
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3960 /*
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3961 * 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
3962 * Parameters:
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3963 * 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
3964 * 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
3965 */
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3966 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
3967 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3968 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
3969 GtkWidget *clist;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3970 int rowcount, z;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3971 char *rowdata;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3972
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3973 DW_MUTEX_LOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3974 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
3975
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3976 if(!clist)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3977 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3978 DW_MUTEX_UNLOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3979 return;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3980 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3981 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
3982
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3983 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
3984 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3985 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
3986 if(rowdata == text)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3987 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3988 gfloat pos;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3989 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
3990
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
3991 _dw_unselect(clist);
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
3992
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3993 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
3994
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3995 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
3996 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
3997 DW_MUTEX_UNLOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3998 return;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3999 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4000 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4001
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4002 DW_MUTEX_UNLOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4003 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4004
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4005 /*
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4006 * 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
4007 * Parameters:
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4008 * 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
4009 */
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4010 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
4011 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4012 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
4013 GtkWidget *clist;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4014 int colcount, z;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4015
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4016 DW_MUTEX_LOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4017 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
4018
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4019 if(!clist)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4020 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4021 DW_MUTEX_UNLOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4022 return;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4023 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4024 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
4025 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
4026 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4027 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
4028 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
4029 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4030 DW_MUTEX_UNLOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4031 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4032
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4033 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4034 * Creates a rendering context widget (window) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4035 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4036 * id: An id to be used with dw_window_from_id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4037 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4038 * A handle to the widget or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4039 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4040 HWND dw_render_new(unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4041 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4042 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4043 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4044
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4045 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4046 tmp = gtk_drawing_area_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4047 gtk_widget_set_events(tmp, GDK_EXPOSURE_MASK
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4048 | GDK_LEAVE_NOTIFY_MASK
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4049 | GDK_BUTTON_PRESS_MASK
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4050 | GDK_POINTER_MOTION_MASK
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4051 | GDK_POINTER_MOTION_HINT_MASK);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4052 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4053 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4054 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4055 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4056 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4057
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4058 /* Sets the current foreground drawing color.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4059 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4060 * red: red value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4061 * green: green value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4062 * blue: blue value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4063 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4064 void dw_color_foreground_set(unsigned long value)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4065 {
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4066 int _locked_by_me = FALSE, index = _find_thread_index(dw_thread_id());
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4067 GdkColor color = { 0, DW_RED_VALUE(value) << 8, DW_GREEN_VALUE(value) << 8, DW_BLUE_VALUE(value) << 8 };
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4068
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4069 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4070 gdk_color_alloc(_dw_cmap, &color);
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4071 _foreground[index] = color;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4072 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4073 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4074
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4075 /* Sets the current background drawing color.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4076 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4077 * red: red value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4078 * green: green value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4079 * blue: blue value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4080 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4081 void dw_color_background_set(unsigned long value)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4082 {
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4083 int _locked_by_me = FALSE, index = _find_thread_index(dw_thread_id());
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4084 GdkColor color = { 0, DW_RED_VALUE(value) << 8, DW_GREEN_VALUE(value) << 8, DW_BLUE_VALUE(value) << 8 };
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4085
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4086 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4087 gdk_color_alloc(_dw_cmap, &color);
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4088 _background[index] = color;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4089 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4090 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4091
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4092 GdkGC *_set_colors(GdkWindow *window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4093 {
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4094 GdkGC *gc = NULL;
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4095 int index = _find_thread_index(dw_thread_id());
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4096
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4097 if(!window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4098 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4099 gc = gdk_gc_new(window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4100 if(gc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4101 {
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4102 gdk_gc_set_foreground(gc, &_foreground[index]);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4103 gdk_gc_set_background(gc, &_background[index]);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4104 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4105 return gc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4106 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4107
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4108 /* Draw a point on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4109 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4110 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4111 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4112 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4113 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4114 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4115 void dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4116 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4117 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4118 GdkGC *gc = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4119
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4120 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4121 if(handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4122 gc = _set_colors(handle->window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4123 else if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4124 gc = _set_colors(pixmap->pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4125 if(gc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4126 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4127 gdk_draw_point(handle ? handle->window : pixmap->pixmap, gc, x, y);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4128 gdk_gc_unref(gc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4129 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4130 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4131 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4132
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4133 /* Draw a line on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4134 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4135 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4136 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4137 * x1: First X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4138 * y1: First Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4139 * x2: Second X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4140 * y2: Second Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4141 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4142 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
4143 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4144 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4145 GdkGC *gc = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4146
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4147 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4148 if(handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4149 gc = _set_colors(handle->window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4150 else if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4151 gc = _set_colors(pixmap->pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4152 if(gc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4153 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4154 gdk_draw_line(handle ? handle->window : pixmap->pixmap, gc, x1, y1, x2, y2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4155 gdk_gc_unref(gc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4156 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4157 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4158 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4159
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4160 /* Draw a rectangle on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4161 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4162 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4163 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4164 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4165 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4166 * width: Width of rectangle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4167 * height: Height of rectangle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4168 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4169 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
4170 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4171 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4172 GdkGC *gc = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4173
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4174 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4175 if(handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4176 gc = _set_colors(handle->window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4177 else if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4178 gc = _set_colors(pixmap->pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4179 if(gc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4180 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4181 gdk_draw_rectangle(handle ? handle->window : pixmap->pixmap, gc, fill, x, y, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4182 gdk_gc_unref(gc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4183 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4184 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4185 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4186
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4187 /* Draw text on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4188 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4189 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4190 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4191 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4192 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4193 * text: Text to be displayed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4194 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4195 void dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4196 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4197 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4198 GdkGC *gc = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4199 GdkFont *font;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4200 char *fontname = "fixed";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4201
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
4202 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
4203 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
4204
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4205 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4206 if(handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4207 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4208 fontname = (char *)gtk_object_get_data(GTK_OBJECT(handle), "fontname");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4209 gc = _set_colors(handle->window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4210 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4211 else if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4212 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4213 fontname = (char *)gtk_object_get_data(GTK_OBJECT(pixmap->handle), "fontname");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4214 gc = _set_colors(pixmap->pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4215 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4216 if(gc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4217 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4218 font = gdk_font_load(fontname);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4219 if(font)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4220 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4221 gint ascent;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4222
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4223 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
4224 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
4225 gdk_gc_unref(gc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4226 gdk_font_unref(font);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4227 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4228 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4229 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4230 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4231
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
4232 /* 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
4233 * 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
4234 * 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
4235 * 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
4236 * 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
4237 * 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
4238 * 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
4239 */
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
4240 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
4241 {
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
4242 int _locked_by_me = FALSE;
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
4243 GdkFont *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
4244 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
4245
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
4246 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
4247 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
4248
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
4249 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
4250 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
4251 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
4252 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
4253 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
4254
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
4255 font = gdk_font_load(fontname ? fontname : "fixed");
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
4256 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
4257 {
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
4258 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
4259 *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
4260 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
4261 *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
4262 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
4263 }
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
4264 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
4265 }
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
4266
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4267 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4268 * Creates a pixmap with given parameters.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4269 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4270 * handle: Window handle the pixmap is associated with.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4271 * width: Width of the pixmap in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4272 * height: Height of the pixmap in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4273 * depth: Color depth of the pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4274 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4275 * A handle to a pixmap or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4276 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4277 HPIXMAP dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4278 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4279 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4280 HPIXMAP pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4281
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4282 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4283 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4284
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4285 if (!depth)
66
664a274a46a6 Fixed color depth problem when creating a new pixmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 63
diff changeset
4286 depth = -1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4287
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4288 pixmap->width = width; pixmap->height = height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4289
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4290
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4291 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4292 pixmap->handle = 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
4293 #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
4294 pixmap->pixmap = (GdkPixmap *)gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, depth, width, height);
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
4295 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4296 pixmap->pixmap = gdk_pixmap_new(handle->window, width, height, depth);
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
4297 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4298 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4299 return pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4300 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4301
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4302 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4303 * Creates a pixmap from internal resource graphic specified by id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4304 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4305 * handle: Window handle the pixmap is associated with.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4306 * id: Resource ID associated with requested pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4307 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4308 * A handle to a pixmap or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4309 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4310 HPIXMAP dw_pixmap_grab(HWND handle, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4311 {
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4312 GdkBitmap *bitmap = NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4313 HPIXMAP pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4314 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4315
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4316 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4317 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4318
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4319
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4320 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
4321 pixmap->pixmap = _find_pixmap(&bitmap, id, handle, &pixmap->width, &pixmap->height);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4322 if(pixmap->pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4323 {
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
4324 #if GTK_MAJOR_VERSION < 2
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4325 GdkPixmapPrivate *pvt = (GdkPixmapPrivate *)pixmap->pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4326 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
4327 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4328 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4329 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4330 return pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4331 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4332
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4333 /* Call this after drawing to the screen to make sure
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4334 * anything you have drawn is visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4335 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4336 void dw_flush(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4337 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4338 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4339
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4340 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4341 gdk_flush();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4342 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4343 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4344
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4345 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4346 * Destroys an allocated pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4347 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4348 * pixmap: Handle to a pixmap returned by
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4349 * dw_pixmap_new..
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4350 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4351 void dw_pixmap_destroy(HPIXMAP pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4352 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4353 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4354
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4355 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
4356 #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
4357 gdk_pixbuf_unref((GdkPixbuf *)pixmap->pixmap);
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
4358 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4359 gdk_pixmap_unref(pixmap->pixmap);
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
4360 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4361 free(pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4362 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4363 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4364
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4365 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4366 * Copies from one item to another.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4367 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4368 * dest: Destination window handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4369 * destp: Destination pixmap. (choose only one).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4370 * xdest: X coordinate of destination.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4371 * ydest: Y coordinate of destination.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4372 * width: Width of area to copy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4373 * height: Height of area to copy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4374 * src: Source window handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4375 * srcp: Source pixmap. (choose only one).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4376 * xsrc: X coordinate of source.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4377 * ysrc: Y coordinate of source.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4378 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4379 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
4380 {
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
4381 /* 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
4382 * 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
4383 * 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
4384 * 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
4385 */
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4386 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4387 GdkGC *gc = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4388
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
4389 if((!dest && (!destp || !destp->pixmap)) || (!src && (!srcp || !srcp->pixmap)))
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4390 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4391
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4392 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4393 if(dest)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4394 gc = _set_colors(dest->window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4395 else if(src)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4396 gc = _set_colors(src->window);
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
4397 #if GTK_MAJOR_VERSION < 1
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4398 else if(destp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4399 gc = gdk_gc_new(destp->pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4400 else if(srcp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4401 gc = gdk_gc_new(srcp->pixmap);
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
4402 #endif
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
4403
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
4404 if(gc
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
4405 #if GTK_MAJOR_VERSION > 2
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
4406 || (!dest && !src)
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
4407 #endif
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
4408 )
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4409 {
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
4410 #if GTK_MAJOR_VERSION < 1
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4411 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
4412 #else
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
4413 if(dest && srcp)
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
4414 gdk_pixbuf_render_to_drawable((GdkPixbuf *)srcp->pixmap, dest->window, gc, xsrc, ysrc, xdest, ydest, width, height, GDK_RGB_DITHER_NONE, 0, 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
4415
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
4416 if(gc)
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
4417 #endif
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
4418 gdk_gc_unref(gc);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4419 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4420 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4421 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4422
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4423 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4424 * Emits a beep.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4425 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4426 * freq: Frequency.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4427 * dur: Duration.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4428 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4429 void dw_beep(int freq, int dur)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4430 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4431 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4432
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4433 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4434 gdk_beep();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4435 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4436 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4437
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4438 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4439 * Returns the handle to an unnamed mutex semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4440 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4441 HMTX dw_mutex_new(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4442 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4443 HMTX mutex;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4444
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4445 pthread_mutex_init(&mutex, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4446 return mutex;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4447 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4448
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4449 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4450 * Closes a semaphore created by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4451 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4452 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4453 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4454 void dw_mutex_close(HMTX mutex)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4455 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4456 pthread_mutex_destroy(&mutex);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4457 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4458
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4459 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4460 * Tries to gain access to the semaphore, if it can't it blocks.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4461 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4462 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4463 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4464 void dw_mutex_lock(HMTX mutex)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4465 {
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
4466 /* 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
4467 * 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
4468 */
baaf4b04d284 Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 94
diff changeset
4469 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
4470 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
4471
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4472 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
4473
baaf4b04d284 Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 94
diff changeset
4474 /* 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
4475 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
4476 gdk_threads_enter();
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4477 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4478
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4479 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4480 * Reliquishes the access to the semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4481 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4482 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4483 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4484 void dw_mutex_unlock(HMTX mutex)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4485 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4486 pthread_mutex_unlock(&mutex);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4487 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4488
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4489 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4490 * Returns the handle to an unnamed event semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4491 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4492 HEV dw_event_new(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4493 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4494 HEV eve = (HEV)malloc(sizeof(struct _dw_unix_event));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4495
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4496 if(!eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4497 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4498
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4499 /* We need to be careful here, mutexes on Linux are
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4500 * FAST by default but are error checking on other
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4501 * systems such as FreeBSD and OS/2, perhaps others.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4502 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4503 pthread_mutex_init (&(eve->mutex), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4504 pthread_mutex_lock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4505 pthread_cond_init (&(eve->event), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4506
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4507 pthread_mutex_unlock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4508 eve->alive = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4509 eve->posted = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4510
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4511 return eve;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4512 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4513
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4514 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4515 * Resets a semaphore created by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4516 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4517 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4518 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4519 int dw_event_reset (HEV eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4520 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4521 if(!eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4522 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4523
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4524 pthread_mutex_lock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4525 pthread_cond_broadcast (&(eve->event));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4526 pthread_cond_init (&(eve->event), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4527 eve->posted = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4528 pthread_mutex_unlock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4529 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4530 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4531
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4532 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4533 * Posts a semaphore created by dw_event_new(). Causing all threads
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4534 * waiting on this event in dw_event_wait to continue.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4535 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4536 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4537 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4538 int dw_event_post (HEV eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4539 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4540 if(!eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4541 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4542
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4543 pthread_mutex_lock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4544 pthread_cond_broadcast (&(eve->event));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4545 eve->posted = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4546 pthread_mutex_unlock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4547 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4548 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4549
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4550 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4551 * Waits on a semaphore created by dw_event_new(), until the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4552 * event gets posted or until the timeout expires.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4553 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4554 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4555 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4556 int dw_event_wait(HEV eve, unsigned long timeout)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4557 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4558 int rc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4559 struct timeval now;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4560 struct timespec timeo;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4561
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4562 if(!eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4563 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4564
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4565 if(eve->posted)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4566 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4567
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4568 pthread_mutex_lock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4569 gettimeofday(&now, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4570 timeo.tv_sec = now.tv_sec + (timeout / 1000);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4571 timeo.tv_nsec = now.tv_usec * 1000;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4572 rc = pthread_cond_timedwait (&(eve->event), &(eve->mutex), &timeo);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4573 pthread_mutex_unlock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4574 if(!rc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4575 return 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4576 if(rc == ETIMEDOUT)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4577 return -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4578 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4579 }
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 * Closes a semaphore created by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4583 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4584 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4585 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4586 int dw_event_close(HEV *eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4587 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4588 if(!eve || !(*eve))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4589 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4590
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4591 pthread_mutex_lock (&((*eve)->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4592 pthread_cond_destroy (&((*eve)->event));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4593 pthread_mutex_unlock (&((*eve)->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4594 pthread_mutex_destroy (&((*eve)->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4595 free(*eve);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4596 *eve = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4597
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4598 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4599 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4600
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4601 /*
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4602 * Setup thread independent color sets.
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4603 */
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4604 void _dwthreadstart(void *data)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4605 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4606 void (*threadfunc)(void *) = NULL;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4607 void **tmp = (void **)data;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4608
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4609 threadfunc = (void (*)(void *))tmp[0];
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4610
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4611 _dw_thread_add(dw_thread_id());
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4612 threadfunc(tmp[1]);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4613 _dw_thread_remove(dw_thread_id());
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4614 free(tmp);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4615 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4616 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4617 * Creates a new thread with a starting point of func.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4618 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4619 * func: Function which will be run in the new thread.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4620 * data: Parameter(s) passed to the function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4621 * stack: Stack size of new thread (OS/2 and Windows only).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4622 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4623 DWTID dw_thread_new(void *func, void *data, int stack)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4624 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4625 DWTID gtkthread;
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4626 void **tmp = malloc(sizeof(void *) * 2);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4627
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4628 tmp[0] = func;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4629 tmp[1] = data;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4630
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4631 pthread_create(&gtkthread, NULL, (void *)_dwthreadstart, (void *)tmp);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4632 return gtkthread;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4633 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4634
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4635 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4636 * Ends execution of current thread immediately.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4637 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4638 void dw_thread_end(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4639 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4640 pthread_exit(NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4641 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4642
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4643 /*
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4644 * Returns the current thread's ID.
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4645 */
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4646 DWTID dw_thread_id(void)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4647 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4648 return (DWTID)pthread_self();
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4649 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4650
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4651 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4652 * Cleanly terminates a DW session, should be signal handler safe.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4653 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4654 * exitcode: Exit code reported to the operating system.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4655 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4656 void dw_exit(int exitcode)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4657 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4658 exit(exitcode);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4659 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4660
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4661 #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
4662
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4663 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4664 * Pack windows (widgets) into a box from the end (or bottom).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4665 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4666 * box: Window handle of the box to be packed into.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4667 * item: Window handle of the item to be back.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4668 * width: Width in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4669 * height: Height in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4670 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4671 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4672 * pad: Number of pixels of padding around the item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4673 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4674 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
4675 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4676 int _locked_by_me = FALSE;
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4677 GtkWidget *tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4678
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4679 if(!box)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4680 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4681
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4682 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4683
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4684 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
4685 box = tmp;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4686
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4687 if(!item)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4688 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4689 item = gtk_label_new("");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4690 gtk_widget_show(item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4691 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4692
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4693 if(GTK_IS_TABLE(box))
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4694 {
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4695 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
4696 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
4697
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4698 /* 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
4699 * 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
4700 * 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
4701 * 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
4702 */
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4703 if(GTK_IS_TABLE(item))
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4704 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4705 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
4706
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4707 if(eventbox)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4708 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4709 gtk_container_add(GTK_CONTAINER(eventbox), item);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4710 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
4711 item = eventbox;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4712 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4713 }
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4714
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4715 if(boxtype == BOXVERT)
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4716 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
4717 else
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4718 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
4719
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4720 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
4721 gtk_object_set_data(GTK_OBJECT(box), "boxcount", (gpointer)boxcount + 1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4722 gtk_widget_set_usize(item, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4723 if(GTK_IS_RADIO_BUTTON(item))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4724 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4725 GSList *group;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4726 GtkWidget *groupstart = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(box), "group");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4727
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4728 if(groupstart)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4729 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4730 group = gtk_radio_button_group(GTK_RADIO_BUTTON(groupstart));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4731 gtk_radio_button_set_group(GTK_RADIO_BUTTON(item), group);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4732 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4733 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4734 gtk_object_set_data(GTK_OBJECT(box), "group", (gpointer)item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4735 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4736 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4737 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4738 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4739 GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4740
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4741 if(GTK_IS_TABLE(item))
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4742 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4743 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
4744
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4745 if(eventbox)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4746 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4747 gtk_container_add(GTK_CONTAINER(eventbox), item);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4748 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
4749 item = eventbox;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4750 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4751 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4752
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4753 gtk_container_border_width(GTK_CONTAINER(box), pad);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4754 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
4755 gtk_box_pack_end(GTK_BOX(vbox), item, TRUE, TRUE, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4756 gtk_widget_show(vbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4757
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4758 gtk_widget_set_usize(item, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4759 gtk_object_set_user_data(GTK_OBJECT(box), vbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4760 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4761 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4762 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4763
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4764 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4765 * Sets the size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4766 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4767 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4768 * width: New width in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4769 * height: New height in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4770 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4771 void dw_window_set_usize(HWND handle, unsigned long width, unsigned long height)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4772 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4773 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4774
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4775 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4776 if(GTK_IS_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4777 _size_allocate(GTK_WINDOW(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4778 #if 0
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4779 gtk_window_set_default_size(GTK_WINDOW(handle), width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4780 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4781 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4782 gtk_widget_set_usize(handle, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4783 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4784 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4785
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4786 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4787 * Returns the width of the screen.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4788 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4789 int dw_screen_width(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4790 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4791 int retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4792 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4793
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4794 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4795 retval = gdk_screen_width();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4796 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4797 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4798 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4799
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4800 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4801 * Returns the height of the screen.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4802 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4803 int dw_screen_height(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4804 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4805 int retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4806 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4807
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4808 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4809 retval = gdk_screen_height();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4810 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4811 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4812 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4813
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4814 /* This should return the current color depth */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4815 unsigned long dw_color_depth(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4816 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4817 int retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4818 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4819
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4820 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
4821 retval = gdk_visual_get_best_depth();
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4822 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4823 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4824 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4825
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4826 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4827 * Sets the position of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4828 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4829 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4830 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4831 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4832 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4833 void dw_window_set_pos(HWND handle, unsigned long x, unsigned long y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4834 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4835 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4836
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4837 DW_MUTEX_LOCK;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
4838 if(handle && handle->window)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4839 gdk_window_move(handle->window, x, y);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4840 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4841 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4842
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4843 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4844 * Sets the position and size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4845 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4846 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4847 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4848 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4849 * width: Width of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4850 * height: Height of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4851 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4852 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
4853 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4854 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4855
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4856 DW_MUTEX_LOCK;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
4857 if(handle && GTK_IS_WINDOW(handle))
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4858 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4859 _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
4860
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
4861 gtk_widget_set_uposition(handle, x, y);
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4862 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
4863 }
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
4864 else if(handle && handle->window)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4865 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4866 gdk_window_resize(handle->window, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4867 gdk_window_move(handle->window, x, y);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4868 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4869 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4870 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4871
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4872 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4873 * Gets the position and size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4874 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4875 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4876 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4877 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4878 * width: Width of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4879 * height: Height of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4880 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4881 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
4882 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4883 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4884 gint gx, gy, gwidth, gheight, gdepth;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4885
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
4886 if(handle && handle->window)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4887 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4888 DW_MUTEX_LOCK;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
4889
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4890 gdk_window_get_geometry(handle->window, &gx, &gy, &gwidth, &gheight, &gdepth);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4891 gdk_window_get_root_origin(handle->window, &gx, &gy);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4892 if(x)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4893 *x = gx;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4894 if(y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4895 *y = gy;
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4896 if(GTK_IS_WINDOW(handle))
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4897 {
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4898 if(width)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4899 *width = gwidth + _dw_border_width;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4900 if(height)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4901 *height = gheight + _dw_border_height;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4902 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4903 else
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4904 {
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4905 if(width)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4906 *width = gwidth;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4907 if(height)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4908 *height = gheight;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4909 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4910 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4911 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4912 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4913
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4914 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4915 * Sets the style of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4916 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4917 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4918 * width: New width in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4919 * height: New height in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4920 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4921 void dw_window_set_style(HWND handle, unsigned long style, unsigned long mask)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4922 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4923 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4924 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4925
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4926 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4927 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4928 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4929 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4930 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4931 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4932 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4933 if(GTK_IS_CLIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4934 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4935 if(style & DW_CCS_EXTENDSEL)
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4936 {
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
4937 gtk_clist_set_selection_mode(GTK_CLIST(handle2), GTK_SELECTION_EXTENDED);
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4938 gtk_object_set_data(GTK_OBJECT(handle2), "multi", (gpointer)1);
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4939 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4940 if(style & DW_CCS_SINGLESEL)
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4941 {
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4942 gtk_clist_set_selection_mode(GTK_CLIST(handle2), GTK_SELECTION_SINGLE);
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4943 gtk_object_set_data(GTK_OBJECT(handle2), "multi", (gpointer)0);
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4944 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4945 }
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4946 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
4947 {
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4948 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
4949 {
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4950 gfloat x, y;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4951
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4952 x = y = DW_LEFT;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4953
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4954 if(style & DW_DT_CENTER)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4955 x = DW_CENTER;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4956
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4957 if(style & DW_DT_VCENTER)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4958 y = DW_CENTER;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4959
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4960 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
4961 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4962 if(style & DW_DT_WORDBREAK)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4963 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
4964 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4965 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4966 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4967
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4968 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4969 * Adds a new page to specified notebook.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4970 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4971 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4972 * flags: Any additional page creation flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4973 * front: If TRUE page is added at the beginning.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4974 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4975 unsigned long dw_notebook_page_new(HWND handle, unsigned long flags, int front)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4976 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4977 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4978 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
4979 GtkWidget **pagearray;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4980
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4981 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
4982 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
4983
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
4984 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
4985 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
4986 for(z=0;z<256;z++)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4987 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
4988 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
4989 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
4990 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
4991 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
4992
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
4993 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
4994 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
4995
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
4996 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
4997 /* 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
4998 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
4999 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
5000 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
5001 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5002 }
15
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
5003 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5004 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
5005
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5006 /* Hopefully this won't happen. */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5007 return 256;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5008 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5009
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5010 /* 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
5011 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
5012 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5013 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
5014 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
5015
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5016 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
5017 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5018 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
5019 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5020 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
5021 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5022 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
5023 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
5024 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5025 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5026 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5027 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
5028 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5029
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5030 /* Return the logical page id from the physical 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
5031 int _get_logical_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
5032 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5033 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
5034 GtkWidget **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
5035 GtkWidget *thispage = gtk_notebook_get_nth_page(GTK_NOTEBOOK(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
5036
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5037 if(pagearray && thispage)
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5038 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5039 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
5040 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5041 if(thispage == 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
5042 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
5043 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5044 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5045 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
5046 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5047
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5048 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5049 * Remove a page from a notebook.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5050 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5051 * handle: Handle to the notebook widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5052 * pageid: ID of the page to be destroyed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5053 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5054 void dw_notebook_page_destroy(HWND handle, unsigned int pageid)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5055 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5056 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
5057 GtkWidget **pagearray;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5058
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5059 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
5060 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
5061 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
5062 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5063 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
5064 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
5065 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
5066 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5067 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5068 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5069
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5070 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5071 * Queries the currently visible page ID.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5072 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5073 * handle: Handle to the notebook widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5074 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5075 unsigned int dw_notebook_page_query(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5076 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5077 int retval, phys;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5078 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5079
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5080 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
5081 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
5082 retval = _get_logical_page(handle, phys);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5083 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5084 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5085 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5086
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5087 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5088 * Sets the currently visibale page ID.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5089 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5090 * handle: Handle to the notebook widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5091 * pageid: ID of the page to be made visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5092 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5093 void dw_notebook_page_set(HWND handle, unsigned int pageid)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5094 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5095 int realpage, _locked_by_me = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5096
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5097 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
5098 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
5099 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
5100 gtk_notebook_set_page(GTK_NOTEBOOK(handle), pageid);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5101 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5102 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5103
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5104
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5105 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5106 * Sets the text on the specified notebook tab.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5107 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5108 * handle: Notebook handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5109 * pageid: Page ID of the tab to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5110 * text: Pointer to the text to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5111 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5112 void dw_notebook_page_set_text(HWND handle, unsigned long pageid, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5113 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5114 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
5115 int realpage, _locked_by_me = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5116
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5117 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
5118 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
5119 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
5120 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5121 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
5122 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
5123
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5124 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
5125 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
5126 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
5127 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5128
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5129 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
5130 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5131 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
5132 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
5133 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
5134 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5135 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5136 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5137
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5138 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5139 * Sets the text on the specified notebook tab status area.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5140 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5141 * handle: Notebook handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5142 * pageid: Page ID of the tab to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5143 * text: Pointer to the text to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5144 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5145 void dw_notebook_page_set_status_text(HWND handle, unsigned long pageid, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5146 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5147 /* TODO (if possible) */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5148 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5149
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5150 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5151 * Packs the specified box into the notebook page.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5152 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5153 * handle: Handle to the notebook to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5154 * pageid: Page ID in the notebook which is being packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5155 * page: Box handle to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5156 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5157 void dw_notebook_pack(HWND handle, unsigned long pageid, HWND page)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5158 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5159 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
5160 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
5161 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
5162 char ptext[100];
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5163
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5164 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
5165 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
5166 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
5167 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
5168 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
5169
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5170 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
5171 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5172 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
5173 return;
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5174 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5175
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5176 /* 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
5177 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
5178 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5179 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
5180 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5181 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
5182 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
5183 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5184 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
5185 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
5186 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
5187 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
5188 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
5189 break;
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5190 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5191 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5192 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5193
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5194 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
5195
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
5196 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
5197
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5198 if(GTK_IS_TABLE(page))
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5199 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5200 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
5201 gtk_container_border_width(GTK_CONTAINER(page), pad);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5202 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5203
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5204 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
5205 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
5206 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
5207 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
5208 else
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5209 gtk_notebook_insert_page(GTK_NOTEBOOK(handle), page, label, 256);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5210 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5211 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5212
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5213 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5214 * Appends the specified text to the listbox's (or combobox) entry list.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5215 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5216 * handle: Handle to the listbox to be appended to.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5217 * text: Text to append into listbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5218 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5219 void dw_listbox_append(HWND handle, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5220 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5221 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5222 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5223
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5224 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5225 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5226 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5227 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5228 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5229 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5230 }
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5231 gtk_object_set_data(GTK_OBJECT(handle), "appending", (gpointer)1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5232 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5233 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5234 GtkWidget *list_item;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5235 GList *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5236 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
5237 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
5238 GdkColor *back = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle2), "backgdk");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5239
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5240 list_item=gtk_list_item_new_with_label(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5241
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5242 if(font)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5243 _set_font(GTK_LIST_ITEM(list_item)->item.bin.child, font);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5244 if(fore && back)
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
5245 _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
5246 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
5247 DW_RGB(back->red, back->green, back->blue));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5248
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5249 tmp = g_list_append(NULL, list_item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5250 gtk_widget_show(list_item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5251 gtk_list_append_items(GTK_LIST(handle2),tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5252 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5253 else if(GTK_IS_COMBO(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5254 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5255 GList *tmp = (GList *)gtk_object_get_user_data(GTK_OBJECT(handle2));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5256 char *addtext = strdup(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5257
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5258 if(addtext)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5259 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5260 tmp = g_list_append(tmp, addtext);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5261 gtk_object_set_user_data(GTK_OBJECT(handle2), tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5262 gtk_combo_set_popdown_strings(GTK_COMBO(handle2), tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5263 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5264 }
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5265 gtk_object_set_data(GTK_OBJECT(handle), "appending", NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5266 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5267 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5268
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5269 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5270 * Clears the listbox's (or combobox) list of all entries.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5271 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5272 * handle: Handle to the listbox to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5273 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5274 void dw_listbox_clear(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5275 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5276 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5277 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5278
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5279 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5280 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5281 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5282 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5283 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5284 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5285 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5286 if(GTK_IS_COMBO(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5287 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5288 GList *list, *tmp = (GList *)gtk_object_get_user_data(GTK_OBJECT(handle2));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5289
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5290 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5291 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5292 list = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5293 while(list)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5294 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5295 if(list->data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5296 free(list->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5297 list=list->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5298 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5299 g_list_free(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5300 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5301 gtk_object_set_user_data(GTK_OBJECT(handle2), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5302 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5303 else if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5304 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5305 int count = dw_listbox_count(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5306
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5307 gtk_list_clear_items(GTK_LIST(handle2), 0, count - 1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5308 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5309 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5310 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5311
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5312 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5313 * Returns the listbox's item count.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5314 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5315 * handle: Handle to the listbox to be counted
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5316 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5317 int dw_listbox_count(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5318 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5319 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5320 int retval = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5321 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5322
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5323 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5324 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5325 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5326 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5327 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5328 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5329 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5330 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5331 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5332 handle2 = GTK_COMBO(handle)->list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5333 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5334 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5335 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5336 GList *list = GTK_LIST(handle2)->children;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5337 while(list)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5338 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5339 list = list->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5340 retval++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5341 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5342 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5343 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5344 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5345 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5346
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5347 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5348 * Sets the topmost item in the viewport.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5349 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5350 * handle: Handle to the listbox to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5351 * top: Index to the top item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5352 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5353 void dw_listbox_set_top(HWND handle, int top)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5354 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5355 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5356 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5357
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5358 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5359 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5360 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5361 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5362 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5363 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5364 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5365 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5366 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5367 int count = dw_listbox_count(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5368 GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5369 float pos, ratio;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5370
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5371 if(count)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5372 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5373 ratio = (float)top/(float)count;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5374
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5375 pos = (ratio * (float)(adj->upper - adj->lower)) + adj->lower;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5376
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5377 gtk_adjustment_set_value(adj, pos);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5378 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5379 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5380 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5381 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5382
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5383 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5384 * Copies the given index item's text into buffer.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5385 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5386 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5387 * index: Index into the list to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5388 * buffer: Buffer where text will be copied.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5389 * length: Length of the buffer (including NULL).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5390 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5391 void dw_listbox_query_text(HWND handle, unsigned int index, char *buffer, unsigned int length)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5392 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5393 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5394 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5395
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5396 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5397 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5398 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5399 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5400 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5401 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5402 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5403 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5404 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5405 handle2 = GTK_COMBO(handle)->list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5406 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5407 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5408 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5409 int counter = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5410 GList *list = GTK_LIST(handle2)->children;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5411
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5412 while(list)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5413 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5414 if(counter == index)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5415 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5416 gchar *text = "";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5417
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5418 if(GTK_IS_LIST_ITEM(list->data))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5419 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5420 GtkListItem *li = GTK_LIST_ITEM(list->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5421
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5422 if(GTK_IS_ITEM(&(li->item)))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5423 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5424 GtkItem *i = &(li->item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5425
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5426 if(GTK_IS_BIN(&(i->bin)))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5427 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5428 GtkBin *b = &(i->bin);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5429
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5430 if(GTK_IS_LABEL(b->child))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5431 gtk_label_get(GTK_LABEL(b->child), &text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5432 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5433 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5434 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5435 else if(GTK_IS_COMBO(handle) && list->data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5436 text = (gchar *)list->data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5437
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5438 strncpy(buffer, (char *)text, length);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5439 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5440 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5441 list = list->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5442 counter++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5443 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5444 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5445 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5446 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5447
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5448 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5449 * Sets the text of a given listbox entry.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5450 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5451 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5452 * index: Index into the list to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5453 * buffer: Buffer where text will be copied.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5454 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5455 void dw_listbox_set_text(HWND handle, unsigned int index, char *buffer)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5456 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5457 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5458 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5459
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5460 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5461 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5462 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5463 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5464 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5465 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5466 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5467 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5468 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5469 handle2 = GTK_COMBO(handle)->list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5470 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5471 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5472 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5473 int counter = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5474 GList *list = GTK_LIST(handle2)->children;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5475
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5476 while(list)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5477 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5478 if(counter == index)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5479 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5480
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5481 if(GTK_IS_LIST_ITEM(list->data))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5482 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5483 GtkListItem *li = GTK_LIST_ITEM(list->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5484
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5485 if(GTK_IS_ITEM(&(li->item)))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5486 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5487 GtkItem *i = &(li->item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5488
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5489 if(GTK_IS_BIN(&(i->bin)))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5490 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5491 GtkBin *b = &(i->bin);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5492
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5493 if(GTK_IS_LABEL(b->child))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5494 gtk_label_set_text(GTK_LABEL(b->child), buffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5495 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5496 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5497 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5498 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5499 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5500 if(list->data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5501 g_free(list->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5502 list->data = g_strdup(buffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5503 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5504 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5505 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5506 list = list->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5507 counter++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5508 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5509 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5510 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5511 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5512
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5513 /*
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5514 * 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
5515 * Parameters:
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5516 * 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
5517 * 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
5518 */
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5519 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
5520 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5521 GtkWidget *handle2 = handle;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5522 int retval = DW_LIT_NONE;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5523 int _locked_by_me = FALSE;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5524
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5525 DW_MUTEX_LOCK;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5526 if(GTK_IS_SCROLLED_WINDOW(handle))
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5527 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5528 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
5529 if(tmp)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5530 handle2 = tmp;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5531 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5532 if(GTK_IS_LIST(handle2))
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5533 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5534 int counter = 0;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5535 GList *list = GTK_LIST(handle2)->selection;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5536 while(list)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5537 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5538 if(counter > where)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5539 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5540 retval = counter;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5541 break;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5542 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5543
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5544 list = list->next;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5545 counter++;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5546 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5547 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5548 DW_MUTEX_UNLOCK;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5549 return retval;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5550 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5551
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5552 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5553 * Returns the index to the item in the list currently selected.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5554 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5555 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5556 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5557 unsigned int dw_listbox_selected(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5558 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5559 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5560 int retval = DW_LIT_NONE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5561 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5562
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5563 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5564 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5565 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5566 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5567 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5568 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5569 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5570 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5571 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5572 retval = (unsigned int)gtk_object_get_data(GTK_OBJECT(handle), "item");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5573 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5574 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5575 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5576 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5577 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5578 int counter = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5579 GList *list = GTK_LIST(handle2)->children;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5580 while(list)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5581 {
19
3e5bff3e55ff Fixed a problem in dw_listbox_selected().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5582 if(list->data == GTK_LIST(handle2)->selection->data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5583 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5584 retval = counter;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5585 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5586 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5587
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5588 list = list->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5589 counter++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5590 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5591 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5592 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5593 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5594 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5595
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5596 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5597 * Sets the selection state of a given index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5598 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5599 * handle: Handle to the listbox to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5600 * index: Item index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5601 * state: TRUE if selected FALSE if unselected.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5602 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5603 void dw_listbox_select(HWND handle, int index, int state)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5604 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5605 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5606 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5607
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5608 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5609 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5610 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5611 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5612 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5613 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5614 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5615 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5616 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5617 handle2 = GTK_COMBO(handle)->list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5618 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5619 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5620 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5621 if(state)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5622 gtk_list_select_item(GTK_LIST(handle2), index);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5623 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5624 gtk_list_unselect_item(GTK_LIST(handle2), index);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5625 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5626 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5627 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5628
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5629 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5630 * Deletes the item with given index from the list.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5631 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5632 * handle: Handle to the listbox to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5633 * index: Item index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5634 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5635 void dw_listbox_delete(HWND handle, int index)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5636 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5637 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5638 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5639
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5640 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5641 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5642 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5643 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5644 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5645 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5646 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5647 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5648 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5649 handle2 = GTK_COMBO(handle)->list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5650 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5651 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5652 gtk_list_clear_items(GTK_LIST(handle2), index, index);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5653 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5654 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5655
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5656 /* Reposition the bar according to the percentage */
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5657 gint _splitbar_size_allocate(GtkWidget *widget, GtkAllocation *event, gpointer data)
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5658 {
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
5659 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
5660 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
5661 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
5662
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5663 /* 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
5664 if(!percent || (lastwidth == event->width && lastheight == event->height))
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5665 return TRUE;
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5666
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5667 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
5668
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5669 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
5670 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
5671
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5672 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
5673 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
5674 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
5675 gtk_paned_set_position(GTK_PANED(widget), (int)(event->height * (*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
5676 return TRUE;
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5677 }
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5678
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
5679 #if GTK_MAJOR_VERSION == 2
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5680 /* Figure out the new percentage */
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
5681 gint _splitbar_accept_position(GtkWidget *widget, gpointer data)
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
5682 {
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
5683 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
5684 int size = 0, position = gtk_paned_get_position(GTK_PANED(widget));
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5685
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
5686 if(!percent)
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5687 return TRUE;
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
5688
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
5689 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
5690 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
5691 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
5692 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
5693
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
5694 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
5695 *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
5696 return TRUE;
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5697 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
5698 #endif
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5699
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5700 /*
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5701 * 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
5702 * Parameters:
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5703 * type: Value can be BOXVERT or BOXHORZ.
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5704 * 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
5705 * 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
5706 * Returns:
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5707 * 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
5708 */
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5709 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
5710 {
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5711 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
5712 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
5713 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
5714
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5715 DW_MUTEX_LOCK;
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5716 if(type == BOXHORZ)
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5717 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
5718 else
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5719 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
5720 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
5721 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
5722 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
5723 *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
5724 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_percent", (gpointer)percent);
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5725 gtk_object_set_data(GTK_OBJECT(topleft), "_dw_splitbar", (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
5726 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
5727 #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
5728 gtk_signal_connect(GTK_OBJECT(tmp), "accept-position", GTK_SIGNAL_FUNC(_splitbar_accept_position), 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
5729 #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
5730 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
5731 #endif
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5732 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
5733 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
5734 return tmp;
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5735 }
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5736
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5737 /*
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5738 * 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
5739 * Parameters:
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5740 * 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
5741 */
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
5742 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
5743 {
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5744 /* We probably need to force a redraw here */
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
5745 float *mypercent = (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
5746
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
5747 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
5748 *mypercent = percent;
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5749 }
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5750
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5751 /*
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5752 * 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
5753 * Parameters:
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
5754 * 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
5755 */
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
5756 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
5757 {
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
5758 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
5759
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
5760 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
5761 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
5762 return 0.0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5763 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5764
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5765 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5766 * Pack windows (widgets) into a box from the start (or top).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5767 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5768 * box: Window handle of the box to be packed into.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5769 * item: Window handle of the item to be back.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5770 * width: Width in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5771 * height: Height in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5772 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5773 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5774 * pad: Number of pixels of padding around the item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5775 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5776 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
5777 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5778 int _locked_by_me = FALSE;
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5779 GtkWidget *tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5780
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5781 if(!box)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5782 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5783
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5784 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5785
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5786 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
5787 box = tmp;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5788
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5789 if(!item)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5790 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5791 item = gtk_label_new("");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5792 gtk_widget_show(item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5793 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5794
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5795 if(GTK_IS_TABLE(box))
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5796 {
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5797 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
5798 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
5799 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
5800
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5801 /* 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
5802 * 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
5803 * 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
5804 * 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
5805 */
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5806 if(GTK_IS_TABLE(item))
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5807 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5808 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
5809
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5810 if(eventbox)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5811 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5812 gtk_container_add(GTK_CONTAINER(eventbox), item);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5813 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
5814 item = eventbox;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5815 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5816 }
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5817
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5818 if(boxtype == BOXVERT)
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5819 {
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5820 x = 0;
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5821 y = boxcount;
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5822 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
5823 }
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5824 else
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5825 {
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5826 x = boxcount;
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5827 y = 0;
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5828 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
5829 }
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5830
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5831 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
5832 gtk_object_set_data(GTK_OBJECT(box), "boxcount", (gpointer)boxcount + 1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5833 gtk_widget_set_usize(item, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5834 if(GTK_IS_RADIO_BUTTON(item))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5835 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5836 GSList *group;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5837 GtkWidget *groupstart = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(box), "group");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5838
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5839 if(groupstart)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5840 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5841 group = gtk_radio_button_group(GTK_RADIO_BUTTON(groupstart));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5842 gtk_radio_button_set_group(GTK_RADIO_BUTTON(item), group);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5843 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5844 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5845 gtk_object_set_data(GTK_OBJECT(box), "group", (gpointer)item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5846 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5847 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5848 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5849 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5850 GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5851
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5852 if(GTK_IS_TABLE(item))
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5853 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5854 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
5855
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5856 if(eventbox)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5857 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5858 gtk_container_add(GTK_CONTAINER(eventbox), item);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5859 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
5860 item = eventbox;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5861 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5862 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5863
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5864 gtk_container_border_width(GTK_CONTAINER(box), pad);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5865 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
5866 gtk_box_pack_end(GTK_BOX(vbox), item, TRUE, TRUE, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5867 gtk_widget_show(vbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5868
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5869 gtk_widget_set_usize(item, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5870 gtk_object_set_user_data(GTK_OBJECT(box), vbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5871 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5872 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5873 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5874
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5875 /*
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
5876 * 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
5877 * 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
5878 * 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
5879 * 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
5880 */
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
5881 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
5882 {
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
5883 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
5884
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
5885 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
5886 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
5887
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
5888 DW_MUTEX_LOCK;
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
5889 gtk_object_set_data(GTK_OBJECT(window), "defaultitem", (gpointer)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
5890 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
5891 }
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
5892
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
5893 /*
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
5894 * 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
5895 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
5896 * 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
5897 * 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
5898 */
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
5899 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
5900 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
5901 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
5902
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
5903 if(!window)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
5904 return;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
5905
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
5906 DW_MUTEX_LOCK;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
5907 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
5908 DW_MUTEX_UNLOCK;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
5909 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
5910
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
5911 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5912 * Returns some information about the current operating environment.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5913 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5914 * env: Pointer to a DWEnv struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5915 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5916 void dw_environment_query(DWEnv *env)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5917 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5918 struct utsname name;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5919 char tempbuf[100];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5920 int len, z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5921
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5922 uname(&name);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5923 strcpy(env->osName, name.sysname);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5924 strcpy(tempbuf, name.release);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5925
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5926 env->MajorBuild = env->MinorBuild = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5927
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5928 len = strlen(tempbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5929
15
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
5930 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
5931 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
5932 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
5933 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
5934 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
5935
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5936 for(z=1;z<len;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5937 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5938 if(tempbuf[z] == '.')
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5939 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5940 tempbuf[z] = '\0';
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5941 env->MajorVersion = atoi(&tempbuf[z-1]);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5942 env->MinorVersion = atoi(&tempbuf[z+1]);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5943 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5944 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5945 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5946 env->MajorVersion = atoi(tempbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5947 env->MinorVersion = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5948 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5949
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5950 /* Internal function to handle the file OK press */
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5951 void _gtk_file_ok(GtkWidget *widget, DWDialog *dwwait)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5952 {
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
5953 #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
5954 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
5955 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5956 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
5957 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5958
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5959 if(!dwwait)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5960 return;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5961
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5962 tmp = gtk_file_selection_get_filename(GTK_FILE_SELECTION(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
5963 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
5964 _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
5965 dw_dialog_dismiss(dwwait, (void *)(tmp ? strdup(tmp) : NULL));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5966 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5967
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5968 /* Internal function to handle the file Cancel press */
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5969 void _gtk_file_cancel(GtkWidget *widget, DWDialog *dwwait)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5970 {
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5971 if(!dwwait)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5972 return;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5973
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5974 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
5975 _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
5976 dw_dialog_dismiss(dwwait, NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5977 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5978
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5979 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5980 * Opens a file dialog and queries user selection.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5981 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5982 * title: Title bar text for dialog.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5983 * defpath: The default path of the open dialog.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5984 * ext: Default file extention.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5985 * flags: DW_FILE_OPEN or DW_FILE_SAVE.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5986 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5987 * NULL on error. A malloced buffer containing
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5988 * the file path on success.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5989 *
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5990 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5991 char *dw_file_browse(char *title, char *defpath, char *ext, int flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5992 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5993 GtkWidget *filew;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5994 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
5995 DWDialog *dwwait;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5996
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5997 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5998
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5999 /* The DW mutex should be sufficient for
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6000 * insuring no thread changes this unknowingly.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6001 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6002 if(_dw_file_active)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6003 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6004 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6005 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6006 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6007
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6008 _dw_file_active = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6009
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6010 filew = gtk_file_selection_new(title);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6011
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6012 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
6013
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6014 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
6015 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
6016
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6017 if(defpath)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6018 gtk_file_selection_set_filename(GTK_FILE_SELECTION(filew), defpath);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6019
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6020 gtk_widget_show(filew);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6021
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6022 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6023
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6024 return (char *)dw_dialog_wait(dwwait);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6025 }
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 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6029 * Execute and external program in a seperate session.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6030 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6031 * program: Program name with optional path.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6032 * type: Either DW_EXEC_CON or DW_EXEC_GUI.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6033 * params: An array of pointers to string arguements.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6034 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6035 * -1 on error.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6036 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6037 int dw_exec(char *program, int type, char **params)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6038 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6039 int ret = -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6040
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6041 if((ret = fork()) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6042 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6043 int i;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6044
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6045 for (i = 3; i < 256; i++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6046 close(i);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6047 setsid();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6048 if(type == DW_EXEC_GUI)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6049 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6050 execvp(program, params);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6051 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6052 else if(type == DW_EXEC_CON)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6053 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6054 char **tmpargs;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6055
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6056 if(!params)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6057 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6058 tmpargs = malloc(sizeof(char *));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6059 tmpargs[0] = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6060 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6061 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6062 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6063 int z = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6064
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6065 while(params[z])
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6066 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6067 z++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6068 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6069 tmpargs = malloc(sizeof(char *)*(z+3));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6070 z=0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6071 tmpargs[0] = "xterm";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6072 tmpargs[1] = "-e";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6073 while(params[z])
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6074 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6075 tmpargs[z+2] = params[z];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6076 z++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6077 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6078 tmpargs[z+2] = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6079 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6080 execvp("xterm", tmpargs);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6081 free(tmpargs);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6082 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6083 /* If we got here exec failed */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6084 _exit(-1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6085 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6086 return ret;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6087 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6088
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6089 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6090 * Loads a web browser pointed at the given URL.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6091 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6092 * url: Uniform resource locator.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6093 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6094 int dw_browse(char *url)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6095 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6096 /* Is there a way to find the webbrowser in Unix? */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6097 char *execargs[3], *browser = "netscape";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6098
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6099 execargs[0] = browser;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6100 execargs[1] = url;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6101 execargs[2] = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6102
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6103 return dw_exec(browser, DW_EXEC_GUI, execargs);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6104 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6105
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6106 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6107 * Returns a pointer to a static buffer which containes the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6108 * current user directory. Or the root directory (C:\ on
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6109 * OS/2 and Windows).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6110 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6111 char *dw_user_dir(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6112 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6113 static char _user_dir[1024] = "";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6114
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6115 if(!_user_dir[0])
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6116 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6117 char *home = getenv("HOME");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6118
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6119 if(home)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6120 strcpy(_user_dir, home);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6121 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6122 strcpy(_user_dir, "/");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6123 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6124 return _user_dir;
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 * Call a function from the window (widget)'s context.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6129 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6130 * handle: Window handle of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6131 * function: Function pointer to be called.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6132 * data: Pointer to the data to be passed to the function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6133 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6134 void dw_window_function(HWND handle, void *function, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6135 {
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6136 void (* windowfunc)(void *);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6137
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6138 windowfunc = function;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6139
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6140 if(windowfunc)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6141 windowfunc(data);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6142 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6143
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
6144 /*
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
6145 * 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
6146 * Parameters:
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
6147 * 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
6148 * 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
6149 * 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
6150 */
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
6151 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
6152 {
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
6153 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
6154
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
6155 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
6156 return;
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
6157
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
6158 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
6159 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
6160 {
cf0115e38ef0 On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
6161 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
6162 {
cf0115e38ef0 On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
6163 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
6164
cf0115e38ef0 On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
6165 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
6166 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
6167 }
cf0115e38ef0 On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
6168 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
6169 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
6170 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
6171 }
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
6172 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
6173 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
6174
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
6175 /*
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
6176 * 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
6177 * Parameters:
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
6178 * 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
6179 * 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
6180 * 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
6181 */
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
6182 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
6183 {
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
6184 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
6185 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
6186
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
6187 if(!window)
92
0a085f295e81 A couple more minor changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 91
diff changeset
6188 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
6189
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
6190 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
6191 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
6192 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
6193 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
6194 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
6195 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
6196
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6197 #ifndef NO_SIGNALS
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6198 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6199 * Add a callback to a window event.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6200 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6201 * window: Window handle of signal to be called back.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6202 * signame: A string pointer identifying which signal to be hooked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6203 * sigfunc: The pointer to the function to be used as the callback.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6204 * data: User data to be passed to the handler function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6205 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6206 void dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6207 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6208 SignalHandler *work = malloc(sizeof(SignalHandler));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6209 void *thisfunc = _findsigfunc(signame);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6210 char *thisname = signame;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6211 HWND thiswindow = window;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6212 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6213
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6214 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6215 if(GTK_IS_SCROLLED_WINDOW(thiswindow))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6216 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6217 thiswindow = (HWND)gtk_object_get_user_data(GTK_OBJECT(window));
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 if(GTK_IS_MENU_ITEM(thiswindow) && strcmp(signame, "clicked") == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6221 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6222 thisname = "activate";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6223 thisfunc = _findsigfunc(thisname);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6224 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6225 else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, "container-context") == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6226 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6227 thisname = "button_press_event";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6228 thisfunc = _findsigfunc("container-context");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6229 }
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
6230 else if(GTK_IS_TREE(thiswindow) && strcmp(signame, "container-context") == 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
6231 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
6232 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
6233
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
6234 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
6235 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
6236 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
6237
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
6238 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
6239 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
6240 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
6241 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
6242 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
6243 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
6244 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6245 else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, "container-select") == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6246 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6247 thisname = "button_press_event";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6248 thisfunc = _findsigfunc("container-select");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6249 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6250 else if(GTK_IS_COMBO(thiswindow) && strcmp(signame, "item-select") == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6251 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6252 thisname = "select_child";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6253 thiswindow = GTK_COMBO(thiswindow)->list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6254 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6255 else if(GTK_IS_LIST(thiswindow) && strcmp(signame, "item-select") == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6256 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6257 thisname = "select_child";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6258 }
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6259 else if(strcmp(signame, "set-focus") == 0)
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
6260 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
6261 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
6262 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
6263 thiswindow = GTK_COMBO(thiswindow)->entry;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
6264 }
55
b6948eac375a Sync with the latest dynamic windows, tree fixes, and other miscellaneous
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 54
diff changeset
6265 else if(strcmp(signame, "lose-focus") == 0)
b6948eac375a Sync with the latest dynamic windows, tree fixes, and other miscellaneous
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 54
diff changeset
6266 {
b6948eac375a Sync with the latest dynamic windows, tree fixes, and other miscellaneous
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 54
diff changeset
6267 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
6268 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
6269 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
6270 }
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
6271 else if(GTK_IS_TREE(thiswindow) && strcmp(signame, "tree-select") == 0)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
6272 {
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
6273 if(thisfunc)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
6274 {
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
6275 gtk_object_set_data(GTK_OBJECT(thiswindow), "select-child-func", (gpointer)thisfunc);
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
6276 gtk_object_set_data(GTK_OBJECT(thiswindow), "select-child-data", (gpointer)work);
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
6277 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
6278 thisname = "select-child";
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
6279 }
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
6280 else if(GTK_IS_VSCALE(thiswindow) || GTK_IS_HSCALE(thiswindow))
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
6281 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
6282 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
6283 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6284
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6285 if(!thisfunc || !thiswindow)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6286 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6287 free(work);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6288 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6289 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6290 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6291
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6292 work->window = window;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6293 work->data = data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6294 work->func = sigfunc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6295
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6296 gtk_signal_connect(GTK_OBJECT(thiswindow), thisname, GTK_SIGNAL_FUNC(thisfunc), work);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6297 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6298 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6299
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6300 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6301 * Removes callbacks for a given window with given name.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6302 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6303 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6304 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6305 void dw_signal_disconnect_by_name(HWND window, char *signame)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6306 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6307 #if 0
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6308 gtk_signal_disconnect_by_name(window, signame);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6309 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6310 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6311
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6312 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6313 * Removes all callbacks for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6314 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6315 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6316 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6317 void dw_signal_disconnect_by_window(HWND window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6318 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6319 #if 0
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6320 gtk_signal_disconnect_by_window(window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6321 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6322 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6323
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6324 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6325 * Removes all callbacks for a given window with specified data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6326 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6327 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6328 * data: Pointer to the data to be compared against.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6329 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6330 void dw_signal_disconnect_by_data(HWND window, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6331 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6332 dw_signal_disconnect_by_data(window, data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6333 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6334 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6335
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6336 #ifdef TEST
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6337 HWND mainwindow,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6338 listbox,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6339 okbutton,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6340 cancelbutton,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6341 lbbox,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6342 stext,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6343 buttonbox,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6344 testwindow,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6345 testbox,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6346 testok,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6347 testcancel,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6348 testbox2,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6349 testok2,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6350 testcancel2,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6351 notebook;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6352 int count = 2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6353
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6354 int test_callback(HWND window, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6355 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6356 dw_window_destroy((HWND)data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6357 /* Return -1 to allow the default handlers to return. */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6358 count--;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6359 if(!count)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6360 exit(0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6361 return -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6362 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6363
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6364 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6365 * Let's demonstrate the functionality of this library. :)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6366 */
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6367 int main(int argc, char *argv[])
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6368 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6369 unsigned long flStyle = DW_FCF_SYSMENU | DW_FCF_TITLEBAR |
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6370 DW_FCF_SHELLPOSITION | DW_FCF_TASKLIST | DW_FCF_DLGBORDER;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6371 int pageid;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6372
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6373 dw_init(TRUE, argc, argv);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6374
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6375 /* Try a little server dialog. :) */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6376 mainwindow = dw_window_new(DW_DESKTOP, "Server", flStyle | DW_FCF_SIZEBORDER | DW_FCF_MINMAX);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6377
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6378 lbbox = dw_box_new(BOXVERT, 10);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6379
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6380 dw_box_pack_start(mainwindow, lbbox, 0, 0, TRUE, TRUE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6381
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6382 stext = dw_text_new("Choose a server:", 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6383
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6384 dw_window_set_style(stext, DW_DT_VCENTER, DW_DT_VCENTER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6385
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6386 dw_box_pack_start(lbbox, stext, 130, 15, FALSE, FALSE, 10);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6387
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6388 listbox = dw_listbox_new(100L, FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6389
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6390 dw_box_pack_start(lbbox, listbox, 130, 200, TRUE, TRUE, 10);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6391
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6392 buttonbox = dw_box_new(BOXHORZ, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6393
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6394 dw_box_pack_start(lbbox, buttonbox, 0, 0, TRUE, TRUE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6395
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6396 okbutton = dw_button_new("Ok", 1001L);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6397
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6398 dw_box_pack_start(buttonbox, okbutton, 50, 30, TRUE, TRUE, 5);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6399
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6400 cancelbutton = dw_button_new("Cancel", 1002L);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6401
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6402 dw_box_pack_start(buttonbox, cancelbutton, 50, 30, TRUE, TRUE, 5);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6403
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6404 /* Set some nice fonts and colors */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6405 dw_window_set_color(lbbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6406 dw_window_set_color(buttonbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6407 dw_window_set_font(stext, "9.WarpSans");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6408 dw_window_set_color(stext, DW_CLR_BLACK, DW_CLR_PALEGRAY);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6409 dw_window_set_font(listbox, "9.WarpSans");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6410 dw_window_set_font(okbutton, "9.WarpSans");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6411 dw_window_set_font(cancelbutton, "9.WarpSans");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6412
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6413 dw_window_show(mainwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6414
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6415 dw_window_set_usize(mainwindow, 170, 340);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6416
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6417 /* Another small example */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6418 flStyle |= DW_FCF_MINMAX | DW_FCF_SIZEBORDER;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6419
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6420 testwindow = dw_window_new(DW_DESKTOP, "Wow a test dialog! :) yay!", flStyle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6421
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6422 testbox = dw_box_new(BOXVERT, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6423
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6424 dw_box_pack_start(testwindow, testbox, 0, 0, TRUE, TRUE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6425
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6426 notebook = dw_notebook_new(1010L, TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6427
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6428 dw_box_pack_start(testbox, notebook, 100, 100, TRUE, TRUE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6429
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6430 testbox = dw_box_new(BOXVERT, 10);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6431
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6432 pageid = dw_notebook_page_new(notebook, 0L, FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6433
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6434 dw_notebook_pack(notebook, pageid, testbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6435
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6436 dw_notebook_page_set_text(notebook, pageid, "Test page");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6437 dw_notebook_page_set_status_text(notebook, pageid, "Test page");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6438
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6439 testok = dw_button_new("Ok", 1003L);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6440
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6441 dw_box_pack_start(testbox, testok, 60, 40, TRUE, TRUE, 10);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6442
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6443 testcancel = dw_button_new("Cancel", 1004L);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6444
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6445 dw_box_pack_start(testbox, testcancel, 60, 40, TRUE, TRUE, 10);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6446
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6447 testbox2 = dw_box_new(BOXHORZ, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6448
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6449 dw_box_pack_start(testbox, testbox2, 0, 0, TRUE, TRUE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6450
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6451 testok2 = dw_button_new("Ok", 1003L);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6452
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6453 dw_box_pack_start(testbox2, testok2, 60, 40, TRUE, TRUE, 10);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6454
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6455 dw_box_pack_splitbar_start(testbox2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6456
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6457 testcancel2 = dw_button_new("Cancel", 1004L);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6458
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6459 dw_box_pack_start(testbox2, testcancel2, 60, 40, TRUE, TRUE, 10);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6460
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6461 /* Set some nice fonts and colors */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6462 dw_window_set_color(testbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6463 dw_window_set_color(testbox2, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6464 dw_window_set_font(testok, "9.WarpSans");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6465 dw_window_set_font(testcancel, "9.WarpSans");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6466 dw_window_set_font(testok2, "9.WarpSans");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6467 dw_window_set_font(testcancel2, "9.WarpSans");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6468
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6469 dw_window_show(testwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6470
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6471 /* Setup the function callbacks */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6472 dw_signal_connect(okbutton, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6473 dw_signal_connect(cancelbutton, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6474 dw_signal_connect(testok, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6475 dw_signal_connect(testcancel, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6476 dw_signal_connect(testok2, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6477 dw_signal_connect(testcancel2, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6478 dw_signal_connect(mainwindow, "delete_event", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6479 dw_signal_connect(testwindow, "delete_event", DW_SIGNAL_FUNC(test_callback), (void *)testwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6480
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6481 dw_main(0L, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6482
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6483 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6484 }
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
6485 #endif
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
6486